Class BodyExecutionCallback
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
BodyExecutionCallback.TailCall,GeneralNonBlockingStepExecution.TailCall
FutureCallback enhanced to track BodyExecution.
Body execution reports the callback in the order onStart(org.jenkinsci.plugins.workflow.steps.StepContext), then either onSuccess(org.jenkinsci.plugins.workflow.steps.StepContext, java.lang.Object) or onFailure(org.jenkinsci.plugins.workflow.steps.StepContext, java.lang.Throwable).
- Author:
- Kohsuke Kawaguchi
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA convenience subclass for the common case that the step expects to run its block just once and return the same value (or throw the same error). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidonFailure(StepContext context, Throwable t) Notifies that the body execution has aborted abnormally.voidonStart(StepContext context) Notifies that the body execution has started.abstract voidonSuccess(StepContext context, Object result) Notifies that the body execution has completed successfully.static BodyExecutionCallbackWraps an ordinaryFutureCallbackintoBodyExecutionCallback.
-
Constructor Details
-
BodyExecutionCallback
public BodyExecutionCallback()
-
-
Method Details
-
onStart
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 callingStepContext.newBodyInvoker().StepContextgiven 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 toStep.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
Notifies that the body execution has completed successfully.StepContextgiven 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 toStep.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
Notifies that the body execution has aborted abnormally.See
onSuccess(StepContext, Object)for the discussion of how the givenStepContextbehaves. -
wrap
public static BodyExecutionCallback wrap(com.google.common.util.concurrent.FutureCallback<Object> v) Wraps an ordinaryFutureCallbackintoBodyExecutionCallback. You lose some power this way (onStart(org.jenkinsci.plugins.workflow.steps.StepContext)and per-bodyStepContext) but may be convenient if you already have aFutureCallbackfrom some other source. For example, you can wrap your ownStepContextif your step is a tail call to its body.
-