Properties in Build
Properties can be set for many different things, including projects, build configurations, process configurations, build requests, and the server. You can also set and retrieve agent properties.
server_url/tools/scripting/ibm-ucb-scripting/The
API documentation contains many useful scripting examples.${p:property_name}${property:property_name}${p:prefix/property_nameFor example, you can refer to a
project property named URL by using the following
syntax:${p:project/URL}@name= syntax. For
example, to retrieve the value of a project property that is named
specific.property, you can use the following syntax:
${p:project/properties[@name='specific.property'}If you do not use a prefix, the property is resolved by the property order of precedence. The following table provides the property order of precedence and the prefix that is used for every context. The property is always resolved in the current context, if possible; otherwise, the property is resolved according to the property order of precedence. The order is resolved from top of the list to bottom.
URL in both the step and job
contexts, both contexts can refer to its own property by using the property
name:${p:URL}If either context refers to the property in the other context,
the prefix can be used. For example, the job can refer to the step property by using this
syntax:${p:step/URL}If a step and a request both have a property that is named URL, then if a job
refers to the property without using a prefix, the property resolves to the step property value. In
this instance, if you want the job to refer to the request context, you must use the prefix:
${p:request/URL}.
${p:buildlife/workflow/project/name}In most cases you
can retrieve the project name with the more straightforward ${p:project/name}, but
this example illustrates how you might handle complicated contexts. | Context | Description |
|---|---|
| Step |
Context: Plug-in job steps. Syntax: |
| Job |
Context: jobs. Syntax: |
| Request |
Context: build requests. Syntax: |
| Source configuration (source plug-in steps only) |
Context: source configuration template steps. Syntax: |
| Source configuration |
Context: source configurations. Syntax:
Source configurations are defined for build processes. |
| Process |
Context: processes. Syntax: |
| Build life |
Context: build life. Syntax: |
| Build life |
Context: build life. Syntax: Returns the current build life ID. The Groovy equivalent is
|
| Build life build process |
Context: build process. Syntax: |
| Build life build request |
Context: build request. Syntax: |
| Project |
Context: project. Syntax: |
| Server |
Context: server. Syntax: Note: There is no context prefix for server properties. Ensure that the names of your server
properties are not duplicated by properties in other scopes.
|
Agent properties
${property_name}${a:property_name}or${agent:property_name}${env/PATH}Property options
Many property elements are scripts. The scripts can be written in JavaScriptâ„¢, Groovy, and BeanShell script. Scripts usually return an object or a value. Property prefixes are scripts that are used to dynamically reference properties in other contexts or scopes. The following table describes the property syntax options.
| Property | Description |
|---|---|
${p:property_name} |
If defined as a non-agent property, return the property value. If the property is not defined, leave the property expression. |
${p?:property_name} |
If defined as a non-agent property, return the property value. If the property is not defined, return an empty string. |
${property_name} |
If defined as an agent property, return the property value. If the property is not defined,
leave the property expression. You can also use the following syntax:
${a:property_name}, or
${agent:property_name}. |
${?:property_name} |
If defined as an agent property, return the property value. If the property is not defined,
return an empty string. You can also use the following syntax:
${a?:property_name}, or
${agent?:property_name}. |
${gvy:script_body} |
Run script_body as Groovy and replace it with the return
value. |
${bsh:script_body} |
Run script_body as BeanShell and replace it with the
return value. |
The startsWith, contains, and matches
functions
startsWith, contains, or matches functions, as
shown in the following code
examples: ${p:fn:startsWith(project/properties, 'prefix')}
${p:fn:contains(project/properties, 'text')}
${p:fn:matches(project/properties, 'prefix.*')}
${p:fn:startsWith(originatingProcess/properties, 'prefix')}
${p:fn:contains(originatingProcess/properties, 'text')}
${p:fn:matches(originatingProcess/properties, 'prefix.*')}
${p:fn:startsWith(process/properties, 'prefix')}
${p:fn:contains(process/properties, 'text')}
${p:fn:matches(process/properties, 'prefix.*')}
${p:fn:startsWith(request/properties, 'prefix')}
${p:fn:contains(request/properties, 'text')}
${p:fn:matches(request/properties, 'prefix.*')}
${p:fn:startsWith(buildlife/properties, 'prefix')}
${p:fn:contains(buildlife/properties, 'text')}
${p:fn:matches(buildlife/properties, 'prefix.*')}
${p:fn:startsWith(agent/properties, 'prefix')}
${p:fn:contains(agent/properties, 'text')}
${p:fn:matches(agent/properties, 'prefix.*')}