Sometimes you may want a resource to perform work for only one job at a time. Because a CloudBees CD/RO agent is capable of executing steps for many jobs on a resource, this can produce undesirable performance results. For example, you might want a dedicated resource to stress test an application or microservice after you have CloudBees CD/RO initiate a load testing task.
This tutorial shows how to reserve a resource for one job step only while that job step is running.
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 locks the resource for the step and executes the tasks.
To demonstrate this functionality, two steps are implemented.
Notice that both steps are set to run in parallel on the local resource.
Both steps request a lock of the resource for the duration of the step execution.
The functionality implemented in each step:
A simple Perl sleep statement to force a lock over a period of time when the procedure is run
Select "Step" in the Retain Exclusive field in the Advanced section on the New/Edit Step page
Click a name in the Step Name column (to go to the Edit Step page for that step). You will see the Perl sleep statement added to the Command text box, and "Step" selected on the Retain Exclusive field.
Instead of running the steps in parallel as you may have previously requested, the steps will now execute serially. The second step must wait for the resource to become available because it was reserved by the first step.
Click Run to run this sample procedure and see the resulting job on the Job Details page.
Create or edit Command Steps for your procedures if you need this functionality.
Go to the Procedure Details page for the procedure where you want a step to reserve a resource.
Add a Command Step to your procedure (use the step creation link at the top of the table), or edit an existing step.
In the Command text box, enter a script if you want to specify any time constraints.
On the New/edit Steps page, in the Advanced section, choose "Step" in the Retain Exclusive field.
The next time you run this procedure, your job step will have exclusive use of the resource you specified.
|Any changes you make within this tutorial will not be saved when you upgrade CloudBees CD/RO.|
Step—create new or edit existing step —Help topic