Class CatchErrorStep
- java.lang.Object
-
- hudson.model.AbstractDescribableImpl<org.jenkinsci.plugins.workflow.steps.Step>
-
- org.jenkinsci.plugins.workflow.steps.Step
-
- org.jenkinsci.plugins.workflow.steps.CatchErrorStep
-
- All Implemented Interfaces:
ExtensionPoint
,Describable<org.jenkinsci.plugins.workflow.steps.Step>
,Serializable
,CatchExecutionOptions
public final class CatchErrorStep extends org.jenkinsci.plugins.workflow.steps.Step implements CatchExecutionOptions
Runs a block. By default, if that block fails, marks the build as failed, but continues execution. Can be customized to print a message when the block fails, to set a different build result, to annotate the step withWarningAction
for advanced visualizations, or to rethrowFlowInterruptedException
rather than continuing execution.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CatchErrorStep.DescriptorImpl
static class
CatchErrorStep.Execution
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Constructor Summary
Constructors Constructor Description CatchErrorStep()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getBuildResult()
Result
getBuildResultOnError()
The result that will be used for setting the build result if an error is caught.String
getMessage()
A message to be printed when an error is caught.String
getStageResult()
Result
getStepResultOnError()
The result that will be used for annotating the withWarningAction
) if an error is caught.boolean
isCatchInterruptions()
WhetherFlowInterruptedException
should be caught and handled by the step or rethrown.void
setBuildResult(String buildResult)
void
setCatchInterruptions(boolean catchInterruptions)
void
setMessage(String message)
void
setStageResult(String stageResult)
org.jenkinsci.plugins.workflow.steps.StepExecution
start(org.jenkinsci.plugins.workflow.steps.StepContext context)
-
-
-
Method Detail
-
getMessage
@CheckForNull public String getMessage()
Description copied from interface:CatchExecutionOptions
A message to be printed when an error is caught. IfCatchExecutionOptions.getStepResultOnError()
(by adding aWarningAction
)- Specified by:
getMessage
in interfaceCatchExecutionOptions
-
setMessage
@DataBoundSetter public void setMessage(String message)
-
getBuildResultOnError
@NonNull public Result getBuildResultOnError()
Description copied from interface:CatchExecutionOptions
The result that will be used for setting the build result if an error is caught. ReturnResult.SUCCESS
to leave the build result unchanged. IfCatchExecutionOptions.isCatchInterruptions()
returnstrue
, then if aFlowInterruptedException
is caught, its result will be used instead of this value.- Specified by:
getBuildResultOnError
in interfaceCatchExecutionOptions
-
getBuildResult
@NonNull public String getBuildResult()
-
setBuildResult
@DataBoundSetter public void setBuildResult(String buildResult)
-
getStepResultOnError
@NonNull public Result getStepResultOnError()
Description copied from interface:CatchExecutionOptions
The result that will be used for annotating the withWarningAction
) if an error is caught. ReturnResult.SUCCESS
to leave the step result unchanged. IfCatchExecutionOptions.isCatchInterruptions()
returnstrue
, then if aFlowInterruptedException
is caught, its result will be used instead of this value.- Specified by:
getStepResultOnError
in interfaceCatchExecutionOptions
-
getStageResult
@NonNull public String getStageResult()
-
setStageResult
@DataBoundSetter public void setStageResult(String stageResult)
-
isCatchInterruptions
public boolean isCatchInterruptions()
Description copied from interface:CatchExecutionOptions
WhetherFlowInterruptedException
should be caught and handled by the step or rethrown.FlowInterruptedException
is commonly used to control the flow of execution for things like builds aborted by a user and builds that time out inside ofTimeoutStep
. It is sometimes desirable to rethrow these kinds of exceptions rather than catching them so as to not interfere with their intended behavior.- Specified by:
isCatchInterruptions
in interfaceCatchExecutionOptions
-
setCatchInterruptions
@DataBoundSetter public void setCatchInterruptions(boolean catchInterruptions)
-
-