Class CpsStepContext

  • All Implemented Interfaces:<Object>, Serializable

    public class CpsStepContext
    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 a CpsStepContext 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 need CpsFlowExecution we do that by following FlowExecutionOwner, and when we need pointers to individual objects inside, we use IDs (such as id}.

    Kohsuke Kawaguchi
    See Also:
    Step.start(StepContext), Serialized Form
    • Method Detail

      • getStepDescriptor

        public org.jenkinsci.plugins.workflow.steps.StepDescriptor getStepDescriptor()
        Obtains StepDescriptor that represents the step this context is invoking.
        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 class
      • isReady

        public boolean isReady()
        Specified by:
        isReady in class org.jenkinsci.plugins.workflow.steps.StepContext
      • hasBody

        public boolean hasBody()
        hasBody in class org.jenkinsci.plugins.workflow.steps.StepContext
      • newBodyInvoker

        public CpsBodyInvoker newBodyInvoker()
        Specified by:
        newBodyInvoker in class org.jenkinsci.plugins.workflow.steps.StepContext
      • newBodyInvoker

        public CpsBodyInvoker newBodyInvoker​(@NonNull
                                             org.jenkinsci.plugins.workflow.cps.BodyReference body,
                                             boolean unexport)
      • getNode

        protected org.jenkinsci.plugins.workflow.graph.FlowNode getNode()
                                                                 throws IOException
        Specified by:
        getNode in class
      • onFailure

        public void onFailure​(Throwable t)
      • onSuccess

        public void onSuccess​(Object returnValue)
        Specified by:
        onSuccess in interface<Object>
        Specified by:
        onSuccess in class org.jenkinsci.plugins.workflow.steps.StepContext
      • setResult

        public void setResult​(Result r)
        Specified by:
        setResult in class org.jenkinsci.plugins.workflow.steps.StepContext
      • saveState

        public<Void> saveState()
        Specified by:
        saveState in class org.jenkinsci.plugins.workflow.steps.StepContext
      • equals

        public boolean equals​(Object o)
        Specified by:
        equals in class org.jenkinsci.plugins.workflow.steps.StepContext
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in class org.jenkinsci.plugins.workflow.steps.StepContext