Interface TaskExecutionContext

All Superinterfaces:
TaskAbortContext

public interface TaskExecutionContext extends TaskAbortContext
Everything a TaskExecutorExtension gets to see and change about the task it is running.

Deliberately narrow, and deliberately free of configuration-item types: no Type, Descriptor, PropertyDescriptor or Task appears in any signature here. Properties are addressed by the names declared in the bundle's type-definitions.xml, so an extension can be unit-tested with a hand-written stub of this interface and no running server.

Instances are supplied per execution and are not thread-safe. Do not retain one beyond the TaskExecutorExtension.execute(com.xebialabs.xlrelease.osgi.api.tasks.TaskExecutionContext) call that received it, and do not use one from a thread you started - its state is written back to the task when execute returns.

  • Method Details

    • isResume

      boolean isResume()
      Whether this is a re-entry rather than the first execution of this task - that is, whether a previous call returned TaskExecutionResult.suspendFor(java.time.Duration) or TaskExecutionResult.awaitSignal().

      This is the hook for writing a state machine in one method: branch on it, and read what the previous entry left in the output properties. Note that because job delivery is at-least-once, a true here does not guarantee the previous entry's work happened exactly once.

    • setOutputProperty

      void setOutputProperty(String name, Object value)
      Sets an output property declared on the task's configuration type. Values are persisted when execute returns, and are visible to later tasks in the release through variable interpolation - and to the next entry of this same extension after a suspend, which is how state is carried across a wait.
      Parameters:
      name - the property name as declared in type-definitions.xml
      value - the value; null withdraws this execution's pending write, leaving the persisted property unchanged — it does NOT clear a previously persisted value (the property layer substitutes declared defaults for null). To visibly reset a property, write a sentinel such as an empty string.
      Throws:
      IllegalArgumentException - if no such property is declared on this type
    • log

      void log(String message)
      Appends a line to the task's execution log - the output a release author reads in the UI when they open the task. This is the plugin's user-facing output channel, and the first place someone will look when a task did something unexpected.

      Distinct from server logging: use your own SLF4J logger for anything aimed at an operator reading server logs rather than at the release author.

      Sensitive values are not scrubbed automatically. Do not log credentials.

    • setStatusLine

      void setStatusLine(String statusLine)
      Sets the task's status line - the short, single-line summary shown next to the task in the release flow, replacing any previous value. Use it for progress ("waiting for build #431"), not for detail; detail belongs in log(String).

      Especially useful before suspending, so the release author can see why a task is still in progress.