Class DefaultTaskExecutionContext
- All Implemented Interfaces:
com.xebialabs.xlrelease.osgi.api.tasks.TaskExecutionContext
TaskExecutionContext, backed by a PluginTask and its configuration.
Reads come straight from the configuration CI; writes are buffered rather than
applied to the CI. That is not an optimisation - the CI a worker holds is a detached copy, and the
only supported way to persist task changes is to hand results back through the release actor
(which ScriptResultsService then applies). Writing directly here would appear to work and
silently lose data.
Most methods are not thread-safe, matching the interface's contract. The output streams,
log(String) and isAborted() are the documented exceptions, because output is
normally produced by whatever is doing the work rather than by the thread that called
execute.
Secrets are not pre-decrypted. A password property is handed out as a Secret whose
reveal() decrypts on demand and records the value in this execution's SecretRegistry,
which is also what the output streams mask against - so anything an extension actually read is
masked, at whatever depth it was found.
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultTaskExecutionContext(com.xebialabs.xlrelease.domain.PluginTask task, boolean resume) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddComment(String markdown) <T> TvoidFlushes and closes both output streams, so a final line with no trailing newline is not lost.List<com.xebialabs.xlrelease.osgi.api.tasks.TaskComment> com.xebialabs.xlrelease.domain.PluginTaskConfiguration<T> Optional<T> getInputProperty(String name, Class<T> type) <T> Optional<T> getOutputProperty(String name, Class<T> type) booleanA plain read of the volatile flag, deliberately not consulting the thread's interrupted status: the interface promises this is thread-safe and, once true, stays true.booleanisResume()voidvoidMarks this execution as aborted, so an extension pollingisAborted()- from any thread - sees it turn true and can return promptly.maskMessage(String message) messagewith every secret revealed in this execution masked.Optional<com.xebialabs.xlrelease.osgi.api.tasks.Secret> Optional<com.xebialabs.xlrelease.osgi.api.tasks.Secret> com.xebialabs.xlrelease.osgi.api.tasks.SecretRegistryThe secrets revealed during this execution, for the worker to install as ambient while the extension runs so that record binding - which has no other route to this context - registers what it reveals for masking.voidsetLogSink(PluginTaskLogSink sink) For the worker to wire the live sink before the extension runs.voidsetOutputProperty(String name, Object value) <T> voidsetOutputs(T record) voidsetStatusLine(String statusLine) com.xebialabs.xlrelease.osgi.api.tasks.TaskOutputstderr()com.xebialabs.xlrelease.osgi.api.tasks.TaskOutputstdout()Everything the extension wrote, ready to hand back through the release actor.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.xebialabs.xlrelease.osgi.api.tasks.TaskExecutionContext
getInputProperty
-
Constructor Details
-
DefaultTaskExecutionContext
public DefaultTaskExecutionContext(com.xebialabs.xlrelease.domain.PluginTask task, boolean resume)
-
-
Method Details
-
getTaskId
- Specified by:
getTaskIdin interfacecom.xebialabs.xlrelease.osgi.api.tasks.TaskExecutionContext
-
getReleaseId
- Specified by:
getReleaseIdin interfacecom.xebialabs.xlrelease.osgi.api.tasks.TaskExecutionContext
-
getTaskType
- Specified by:
getTaskTypein interfacecom.xebialabs.xlrelease.osgi.api.tasks.TaskExecutionContext
-
isResume
public boolean isResume()- Specified by:
isResumein interfacecom.xebialabs.xlrelease.osgi.api.tasks.TaskExecutionContext
-
getConfiguration
public com.xebialabs.xlrelease.domain.PluginTaskConfiguration getConfiguration()- Specified by:
getConfigurationin interfacecom.xebialabs.xlrelease.osgi.api.tasks.TaskExecutionContext
-
bind
- Specified by:
bindin interfacecom.xebialabs.xlrelease.osgi.api.tasks.TaskExecutionContext
-
getInputProperty
- Specified by:
getInputPropertyin interfacecom.xebialabs.xlrelease.osgi.api.tasks.TaskExecutionContext
-
secret
- Specified by:
secretin interfacecom.xebialabs.xlrelease.osgi.api.tasks.TaskExecutionContext
-
secret
public Optional<com.xebialabs.xlrelease.osgi.api.tasks.Secret> secret(com.xebialabs.deployit.plugin.api.udm.ConfigurationItem ci, String name) - Specified by:
secretin interfacecom.xebialabs.xlrelease.osgi.api.tasks.TaskExecutionContext
-
maskMessage
messagewith every secret revealed in this execution masked. For text that leaves the worker outside the output streams, such as a failure message. -
secretRegistry
public com.xebialabs.xlrelease.osgi.api.tasks.SecretRegistry secretRegistry()The secrets revealed during this execution, for the worker to install as ambient while the extension runs so that record binding - which has no other route to this context - registers what it reveals for masking. -
setOutputs
public <T> void setOutputs(T record) - Specified by:
setOutputsin interfacecom.xebialabs.xlrelease.osgi.api.tasks.TaskExecutionContext
-
setOutputProperty
- Specified by:
setOutputPropertyin interfacecom.xebialabs.xlrelease.osgi.api.tasks.TaskExecutionContext
-
getOutputProperty
- Specified by:
getOutputPropertyin interfacecom.xebialabs.xlrelease.osgi.api.tasks.TaskExecutionContext
-
stdout
public com.xebialabs.xlrelease.osgi.api.tasks.TaskOutput stdout()- Specified by:
stdoutin interfacecom.xebialabs.xlrelease.osgi.api.tasks.TaskExecutionContext
-
stderr
public com.xebialabs.xlrelease.osgi.api.tasks.TaskOutput stderr()- Specified by:
stderrin interfacecom.xebialabs.xlrelease.osgi.api.tasks.TaskExecutionContext
-
log
- Specified by:
login interfacecom.xebialabs.xlrelease.osgi.api.tasks.TaskExecutionContext
-
isAborted
public boolean isAborted()A plain read of the volatile flag, deliberately not consulting the thread's interrupted status: the interface promises this is thread-safe and, once true, stays true. An interrupt is neither - it is invisible to a thread the extension started itself, and is cleared by anycatch (InterruptedException)along the way.- Specified by:
isAbortedin interfacecom.xebialabs.xlrelease.osgi.api.tasks.TaskExecutionContext
-
markAborted
public void markAborted()Marks this execution as aborted, so an extension pollingisAborted()- from any thread - sees it turn true and can return promptly.Called by
PluginTaskAbortRegistrywhen a release author aborts the task. One-way: nothing clears it, which is what lets the interface promise that it stays true. -
setLogSink
For the worker to wire the live sink before the extension runs. -
closeOutputs
public void closeOutputs()Flushes and closes both output streams, so a final line with no trailing newline is not lost.Called by the worker on every path once
executehas returned or thrown. -
setStatusLine
- Specified by:
setStatusLinein interfacecom.xebialabs.xlrelease.osgi.api.tasks.TaskExecutionContext
-
addComment
- Specified by:
addCommentin interfacecom.xebialabs.xlrelease.osgi.api.tasks.TaskExecutionContext
-
getComments
- Specified by:
getCommentsin interfacecom.xebialabs.xlrelease.osgi.api.tasks.TaskExecutionContext
-
toResults
Everything the extension wrote, ready to hand back through the release actor.- Parameters:
resumeDelaySeconds- from asuspendForoutcome, elsenullawaitSignal- true for anawaitSignaloutcome
-