Creating and Running Procedures
Procedures are the basic automation objects in CloudBees CD/RO. They are used to implement tool integrations and can be used for almost any automation task, such as running scripts and command line actions. They can also be used as one of the Service Catalog item types, as you will see in the next lab.
Procedures are made up of steps. A command step invokes a block of shell or script commands on a CloudBees CD/RO agent.
In this example, you create a very simple procedure that:
- Produces standard I/O output from a CloudBees CD/RO agent machine.
Because procedures run inside of projects, you must create a project first.
Create a Project
Before you create a procedure, you need to create a container for the procedure, which is called a project. Projects are root-level objects that can contain procedures, pipelines, releases, applications, and other modeling objects. For more information about objects, see Understanding CloudBees CD/RO objects.
To create a project:
- Select the CloudBees CD/RO main menu (the hamburger icon in the top left).
- Navigate to DevOps Essentials > Projects. The project list appears.
- Select New + in the upper right. The New Project dialog appears.
- Select Create New.
- Enter the project name Trial Guide (or similar name) and then select OK. You will not be using credentials (secrets), so when asked if you want to create or edit credentials, select No.
Although we are not using credentials with this simple procedure you will definitely need to create/use credentials from more complicated procedures. Credentials are used to access services and resources used during application deployments, release pipeline execution, or any other automated process orchestrated by CloudBees CD/RO. When a run-time object is configured to run as a specific user other than that defined at install time, CloudBees CD/RO retrieves the user name and password from a stored credential. The credential is passed to the CloudBees CD/RO agent over an encrypted channel so the agent can authenticate itself to the operating system and set up a security context where the object runs with the user permissions in the credential.
- After the project is created, search for it by name by entering Trial Guide in the project search box and hitting return. When it is displayed, select the menu under Actions (three vertical dots) to access the project’s attributes.
Create a procedure
Now that you have a project to contain objects, do the following to create a procedure.
- From the CloudBees CD/RO main menu (top left), navigate to DevOps Essentials > Procedures. The list of procedure objects displays.
- Select New + in the upper right to add a procedure to your project. The New procedure dialog displays.
- Select Create New.
- Enter a procedure name such as Trial Procedure. Select the target project that you created above (for example, Trial Guide) and then select OK (the other default values are fine for this simple procedure).
- You are now in a procedure. The Hierarchy Menu on the left appears, as well as a procedure menu on the right.
Add a procedure step
In order for a procedure to actually do anything it needs 1 or more steps. When a procedure is first created, it has no steps to execute, so you must add steps.
- Select the There are no Steps. Add one + link to begin adding a step. The New Procedure Step dialog appears.
- Select Create New.
- Provide a name, Hello World, and a description for the step — A step to echo out a simple message.
- Select Definition in the upper right of the dialog to define the functionality of the step.
- In the Command field, enter the following command to be run:
- Select OK.
- Your Hello World step is displayed in the list of steps and the Hierarchy Menu of your Trial Procedure.
Run the procedure for the first time
- Click the Run Procedure button (green arrow) on the right, and then select New Run.
- The Run Procedure dialog box appears. Select OK. Note the job’s progress.
- View the job details by clicking the Runs breadcrumb link, then click the link of the last Run Instance. On the Run Details page, click the job run Name link to be able to view the job run details and access step logs.
- Select the icon under Log to view the log output for the Hello World step.
- You should see the Hello world message in the logs of the Hello World step.
- Close the job dialog by clicking the X in the top right corner.