Storing and Retrieving Properties in a Job

2 minute readAutomation

This tutorial shows you how to create, set, and retrieve properties stored on a job.

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 two steps.

  • Write data to a property attached to the running job: "Step 1—Create a property attached to the job" calls ectool to create a property name property1.

  • The path to the property being set is " /jobs/$[/myJob]/property1.

  • $[/myJob] is a shortcut to the running job name and can be used while the job is running. If the job number was 1000, the path " /jobs/$[/myJob]/property1 " might expand to " /jobs/job-1000/property1 ".

  • Read data from the property created in Step 1: "Step 2—Read the property attached to the job by Step 1"—this step could read step values stored on a job, running as part of the job, or could be executed using a simple property expansion.

  • In this case, property1 was set in Step 1 and is referenced in Step 2 using the $[property1] notation.

  • Two other ways to reference a property (shown by example in the Action column):

  • Using $[/myJob/property1]

  • Using inline JavaScript with the notation $[/javascript myJob.property1]

Click Run to run this sample procedure and see the resulting job on the Job Details page.

  • After the job completes, click the icon in the Log column for Step 2 to view three lines each showing the data (the property value) that was stored in the property that was retrieved.

Implementation

If you need to retrieve properties, adapt these concepts to your procedures.

  • For help getting started, click on a step name in the tutorial procedure to go to the corresponding Edit Step page.

  • You can reuse the text supplied in the Command(s) box, changing the "property1" name and other values to those more meaningful to your project/procedure.

Any changes you make within this tutorial will not be saved when you upgrade CloudBees CD/RO.