Class BodyExecutionCallback

java.lang.Object
org.jenkinsci.plugins.workflow.steps.BodyExecutionCallback
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
BodyExecutionCallback.TailCall, GeneralNonBlockingStepExecution.TailCall

public abstract class BodyExecutionCallback extends Object implements Serializable
Author:
Kohsuke Kawaguchi
See Also:
  • Constructor Details

    • BodyExecutionCallback

      public BodyExecutionCallback()
  • Method Details

    • onStart

      public void onStart(StepContext context)
      Notifies that the body execution has started.

      This callback has to return synchronously. It is intended for performing log output, update FlowNode, or some such decorative actions. For any asynchronous computation that needs to happen prior to the body execution, the best place to do that is before calling StepContext.newBodyInvoker().

      StepContext given to this method lets you access objects that correspond to the beginning of the body, as opposed to the objects that correspond to the invocation of the step that invoked the body. Otherwise the context is identical in behaviour to that given to Step.start(StepContext).

      So for example this is a good place to record any logging that's attributed to the body execution, such as reporting that this is Nth retry of the body, or that this is the parallel branch named 'xyz'.

    • onSuccess

      public abstract void onSuccess(StepContext context, Object result)
      Notifies that the body execution has completed successfully.

      StepContext given to this method lets you access objects that correspond to the end of the body, as opposed to the objects that correspond to the invocation of the step that invoked the body. Otherwise the context is identical in behaviour to that given to Step.start(StepContext).

      So for example this is a good place to record any logging that's attributed to the end of the body execution.

    • onFailure

      public abstract void onFailure(StepContext context, Throwable t)
      Notifies that the body execution has aborted abnormally.

      See onSuccess(StepContext, Object) for the discussion of how the given StepContext behaves.

    • wrap

      public static BodyExecutionCallback wrap(com.google.common.util.concurrent.FutureCallback<Object> v)
      Wraps an ordinary FutureCallback into BodyExecutionCallback. You lose some power this way (onStart(org.jenkinsci.plugins.workflow.steps.StepContext) and per-body StepContext) but may be convenient if you already have a FutureCallback from some other source. For example, you can wrap your own StepContext if your step is a tail call to its body.
      See Also: