This tutorial shows common ways to read and write properties on a procedure. For this tutorial, familiarity with creating procedures and steps is assumed. See Related Information if you would like to review these topics.
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 the following functionality:
This procedure implements five steps. Each step name is a description of its action.
Click on a step name to go to the corresponding Edit Step page to see how the step was created. This page also contains text in the Description text box to describe what you see in the Action column on the Procedure Details page. The full text of what appears in the Action column is provided in the Command text box.
In the Custom Procedure Properties table, notice two properties were created:
There are numerous ways to work with stored properties. Each of the steps described below illustrates a different method.
Read data from property1 using the property substitution notation (syntax): The property value is read in this step using the property substitution reference
Read data from a property1 using the CloudBees CD Perl API: Perl code is used to call the CloudBees CD API to retrieve the value of
getPropertyAPI returns an object so the property value must be retrieved after the
getPropertycall, using the
findnodesmethod for the returned object.
#read the property
my $property1node = $ec→getProperty(“/myProcedure/property1”);
#retrieve the property value from the object returned to $property1node
my $property1 = $property1node→findnodes(“//value”)→string_value();
Read data from property1 using ectool: ectool code is used to retrieve the value of
ectool getProperty "/projects/$[/myProject/projectName]/procedures/Working with properties stored in a procedure/property1"
Click Run to run this sample procedure and see the results on the Job Details page. On the Job Details page, click the icon in the Log column to see the value read from the property.
If you need to retrieve properties stored in a procedure, adapt any one of these step concepts to your procedures. You can reuse the text supplied in the Command(s) box (from any Edit Step page in this tutorial), changing names 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.|
Procedure—create new or edit existing procedure —Help topic
Step—create new or edit existing step —Help topic
Properties —Help topic