A PropertyBag
resource is used to pass information from one pipeline to another and provide environment variables to a step in the format of a resource.
A PropertyBag resource can have any string as property, which is then available as environment variables when the key is an input to a step. When it is an output, steps can change the values of properties or add new ones.
YAML Schema
resources: - name: <string> type: PropertyBag configuration: <string>: <string> <string>: <string> pin: versionId: <number> <string>: <string> <string>: <string>
Tags
name
An alphanumeric string (underscores are permitted) that identifies the resource.
type
Must be PropertyBag
for this resource type.
configuration
Specifies all configuration selections for the resource.
Tag | Description | Required/Optional |
---|---|---|
| A property for the PropertyBag resource. The tag should be a valid variable name (Bash or PowerShell) for the steps where it is to be an input or output and the value a string. At least one is required, multiple properties are allowed. | Required |
| This configuration can be used to pin the resource to a specific version. The pinned resource version will be used by the steps that reference this resource as an input and newer versions will be ignored. Users have two configuration options when selecting the PropertyBag resource version to be pinned:
Or
Steps that use the resource as an output can still produce new versions. New versions will be visible for steps using the resource as an input as long as they are part of the same run of the step that created the version. When creating a new run, manual custom trigger can still be used to override the pinned version to a different one. | Optional |
Environment Variables
Whenever PropertyBag
is used in a step, a set of environment variables is automatically made available that you can use in your step.
Environment Variable | Description |
---|---|
res_<resource_name>_<property> | Each property in the PropertyBag resource will be available as an environment variable in this format. |
<property> | If a PropertyBag resource is in inputResources, the properties will also be exported as environment variables with the tag as the variable name. |
Examples
The Pipelines DSL for this example is available in this repository in the JFrog GitHub account.
Example 1
resources: - name: propertyBag_1 type: PropertyBag configuration: property1: "jfrog" property2: "pipelines" pipelines: - name: pipeline_PropertyBag_1 steps: - name: step_propertyBag_1 type: PowerShell configuration: nodePool: win_2019 inputResources: - name: propertyBag_1 execution: onExecute: - write_output "onExecute" - get-variable -name property1 - get-variable -name property2 onSuccess: - write_output "onSuccess"
Example 2
This example uses two steps, step1
and step2
. When the pipeline runs, the step step2
is triggered, but the step step1
is skipped. This is because, the newVersionOnly
tag is set as true
for the myResource
input resource that is used in this step. During a run, if an input resource's version is not updated and if the newVersionOnly
tag is set as true, it causes the step using that input resource to be skipped.
resources: - name: myResource type: PropertyBag configuration: runNumber: 0 pipelines: - name: myPipeline steps: - name: input1 type: Bash configuration: outputResources: - name: myResource execution: onExecute: - write_output myResource runNumber=${run_number} - echo "test" - name: step1 type: Bash configuration: inputResources: - name: myResource newVersionOnly: true execution: onExecute: - echo "test" - name: step2 type: Bash configuration: inputResources: - name: myResource execution: onExecute: - echo "test"