public abstract class StepContext extends Object implements com.google.common.util.concurrent.FutureCallback<Object>, Serializable
Step
.
In a flow, would be created by a FlowExecution
.
It is serializable so a step which may survive a Jenkins restart is free to save it.
StepContext
is only valid until the result is set via FutureCallback
.
Beyond that point, callers are not allowed to call any of the methods.
Constructor and Description |
---|
StepContext() |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
equals(Object o)
StepContext s get persisted, so they may not have the identity equality, but equals
method would allow two instances to be compared. |
abstract <T> T |
get(Class<T> key)
Tries to find a contextually available object.
|
boolean |
hasBody()
Checks if this step was called with a body.
|
abstract int |
hashCode()
Needs to be overridden as the
equals(Object) method is overridden. |
abstract boolean |
isReady()
Whether
get(java.lang.Class<T>) is ready to return values. |
abstract BodyInvoker |
newBodyInvoker()
Prepares for an asynchronous invocation of the body block that's given as an argument
to this step invocation (in a host language dependent manner.)
|
abstract void |
onSuccess(Object result) |
abstract com.google.common.util.concurrent.ListenableFuture<Void> |
saveState()
Requests that any state held by the
StepExecution be saved to disk. |
abstract void |
setResult(hudson.model.Result r)
Sets the overall result of the flow.
|
@Nullable public abstract <T> T get(Class<T> key) throws IOException, InterruptedException
Launcher
EnvVars
FilePath
Launcher.ProcStarter.pwd(hudson.FilePath)
Computer
Executor
TaskListener
LogAction
for a flow)
Run
FlowExecution
a running flow
FlowNode
key
- the kind of thing we wantStepDescriptor.getRequiredContext()
includes it), else nullIOException
- If StepContext
gets serialized, Jenkins restarts, deserialized later, and
Step
tries to get additional context objects, it can be that the corresponding
FlowExecution
could be non-existent (for example, the run that was driving the flow
could have failed to load.) This exception is thrown in such situations just like
FlowExecutionOwner.get
throws IOException.InterruptedException
public abstract void onSuccess(@Nullable Object result)
onSuccess
in interface com.google.common.util.concurrent.FutureCallback<Object>
public abstract boolean isReady()
get(java.lang.Class<T>)
is ready to return values.
May be called to break deadlocks during reloading.public abstract com.google.common.util.concurrent.ListenableFuture<Void> saveState()
StepExecution
be saved to disk.
Useful when a long-running step has changed some instance fields (or the content of a final field) and needs these changes to be recorded.
An implementation might in fact save more state than just the associated step execution, but it must save at least that much.public abstract void setResult(hudson.model.Result r)
Run.setResult(hudson.model.Result)
, can only make the result worse than it already is.
Since some flows may have try-catch semantics, if a step fails to complete normally it is better to use FutureCallback.onFailure(Throwable)
instead.
(For example with FlowInterruptedException
.)r
- Result.UNSTABLE
, typicallypublic abstract BodyInvoker newBodyInvoker() throws IllegalStateException
When the block is completed normally or abnormally, you can have have the callback invoked. The invocation will not get scheduled until you start it.
StepDescriptor.takesImplicitBlockArgument()
must be true.
IllegalStateException
- if hasBody()
is falsepublic boolean hasBody()
StepDescriptor.takesImplicitBlockArgument()
is true, and such a body was in fact passed in; false otherwisepublic abstract boolean equals(Object o)
StepContext
s get persisted, so they may not have the identity equality, but equals
method would allow two instances to be compared.equals
in class Object
StepContext
s are for the same context for the same execution.public abstract int hashCode()
equals(Object)
method is overridden.Copyright © 2016–2017. All rights reserved.