Class CpsStepContext
- java.lang.Object
-
- org.jenkinsci.plugins.workflow.steps.StepContext
-
- org.jenkinsci.plugins.workflow.support.DefaultStepContext
-
- org.jenkinsci.plugins.workflow.cps.CpsStepContext
-
- All Implemented Interfaces:
com.google.common.util.concurrent.FutureCallback<Object>
,Serializable
public class CpsStepContext extends org.jenkinsci.plugins.workflow.support.DefaultStepContext
StepContext
implementation for CPS.This context behaves in two modes. It starts in the synchronous mode, where if a result is set (or exception is thrown), it just gets recoded. When passed into
Step.start(StepContext)
, it's in this mode.When
Step.start(StepContext)
method returns, we'll atomically check if the result is set or not and then switch to the asynchronous mode. In this mode, if the result is set, it'll trigger the rehydration of the workflow. If aCpsStepContext
gets serialized, it'll be deserialized in the asynchronous mode.This object must be serializable on its own without sucking in any of the
CpsFlowExecution
object graph. Wherever we needCpsFlowExecution
we do that by followingFlowExecutionOwner
, and when we need pointers to individual objects inside, we use IDs (such asid
}.- Author:
- Kohsuke Kawaguchi
- See Also:
Step.start(StepContext)
, Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <T> T
doGet(Class<T> key)
boolean
equals(Object o)
String
getDisplayName()
protected CpsFlowExecution
getExecution()
protected org.jenkinsci.plugins.workflow.graph.FlowNode
getNode()
org.jenkinsci.plugins.workflow.steps.StepDescriptor
getStepDescriptor()
ObtainsStepDescriptor
that represents the step this context is invoking.boolean
hasBody()
int
hashCode()
boolean
isReady()
CpsBodyInvoker
newBodyInvoker()
CpsBodyInvoker
newBodyInvoker(org.jenkinsci.plugins.workflow.cps.BodyReference body, boolean unexport)
void
onFailure(Throwable t)
void
onSuccess(Object returnValue)
com.google.common.util.concurrent.ListenableFuture<Void>
saveState()
void
setResult(Result r)
String
toString()
-
-
-
Method Detail
-
getStepDescriptor
@CheckForNull public org.jenkinsci.plugins.workflow.steps.StepDescriptor getStepDescriptor()
ObtainsStepDescriptor
that represents the step this context is invoking.- Returns:
- This method returns null if the step descriptor used is not recoverable in the current VM session, such as when the plugin that implements this was removed. So the caller should defend against null.
-
getDisplayName
public String getDisplayName()
-
getExecution
protected CpsFlowExecution getExecution() throws IOException
- Specified by:
getExecution
in classorg.jenkinsci.plugins.workflow.support.DefaultStepContext
- Throws:
IOException
-
isReady
public boolean isReady()
- Specified by:
isReady
in classorg.jenkinsci.plugins.workflow.steps.StepContext
-
hasBody
public boolean hasBody()
- Overrides:
hasBody
in classorg.jenkinsci.plugins.workflow.steps.StepContext
-
newBodyInvoker
public CpsBodyInvoker newBodyInvoker()
- Specified by:
newBodyInvoker
in classorg.jenkinsci.plugins.workflow.steps.StepContext
-
newBodyInvoker
@NonNull public CpsBodyInvoker newBodyInvoker(@NonNull org.jenkinsci.plugins.workflow.cps.BodyReference body, boolean unexport)
-
doGet
protected <T> T doGet(Class<T> key) throws IOException, InterruptedException
- Specified by:
doGet
in classorg.jenkinsci.plugins.workflow.support.DefaultStepContext
- Throws:
IOException
InterruptedException
-
getNode
protected org.jenkinsci.plugins.workflow.graph.FlowNode getNode() throws IOException
- Specified by:
getNode
in classorg.jenkinsci.plugins.workflow.support.DefaultStepContext
- Throws:
IOException
-
onFailure
public void onFailure(Throwable t)
-
onSuccess
public void onSuccess(Object returnValue)
- Specified by:
onSuccess
in interfacecom.google.common.util.concurrent.FutureCallback<Object>
- Specified by:
onSuccess
in classorg.jenkinsci.plugins.workflow.steps.StepContext
-
setResult
public void setResult(Result r)
- Specified by:
setResult
in classorg.jenkinsci.plugins.workflow.steps.StepContext
-
saveState
public com.google.common.util.concurrent.ListenableFuture<Void> saveState()
- Specified by:
saveState
in classorg.jenkinsci.plugins.workflow.steps.StepContext
-
equals
public boolean equals(Object o)
- Specified by:
equals
in classorg.jenkinsci.plugins.workflow.steps.StepContext
-
hashCode
public int hashCode()
- Specified by:
hashCode
in classorg.jenkinsci.plugins.workflow.steps.StepContext
-
-