Complex processes can be brittle so CloudBees CD/RO provides a way to account for different errors in your procedures. You can specify timeouts, error handling methods, and steps that always run no matter what errors have occurred in preceding steps in the procedure. These facilities can make sure your build does not "hang" in a situation where you would prefer the build to continue.
This tutorial shows how to construct a procedure so processes are terminated after a set time period and how to implement a step that always runs in the event of an error (to perform cleanup).
To view an example procedure for this tutorial , go to the automation platform UI > Projects > EC-Tutorials- <version> , and click the procedure name.
An explanation of what you see:
This procedure implements 2 steps: (Clicking on the step name takes you to the Edit Step page to see how the step was created.)
-
The "force timeout" step has a 10-second timeout and is set to abort the procedure and terminate running steps in the event of a timeout or error.
This step executes a sleep command using ec-perl, which makes the step execute for 15 seconds. Step error handling is set to "Abort procedure and terminate running steps". This step will always fail because the 15-second sleep time is longer than the 10-second timeout.
-
The "always run" step set to run no matter what the error handling behavior is for any preceding steps.
This step uses an echo statement to output some text. The step property,
Always Run Step
, is set to "true" so this step runs regardless of the result for the preceding step.
Click Run to run this sample procedure and see the resulting job on the Job Details page.
On the Job Details page: Notice that the "always run" step completed with Success while the "force timeout" step completed with a TIMEOUT error.
Implementation
This tutorial is intended for viewing only. Any changes you might make within this tutorial cannot be transferred to your projects will not be saved when you upgrade CloudBees CD/RO. |
As you create steps for your projects, you can duplicate these tutorial concepts. On the New Steps page, review the Advanced section. Notice the Error Handling and Always Run Steps options.
-
For Error Handling, choose the option that best suits your purpose.
-
For the Always Run Step option, select the checkbox to ensure this step will always run.