A step that specifies a resource can access the resource and its attributes through environment variables.
These environment variables have a standard naming convention:
res_<resource name>_<tag>This can be extended further to access an integration that is specified in the resource: res_<resource_name>_<integration tag name>_<tag>
Example
If the definition of a GitRepo resource named
app_gitrepois as follows:GitRepo Resource Definition
resources: - name: app_gitRepo type: GitRepo configuration: path: user1/repo1 gitProvider: myGitProviderThe environment variable definition would be as follows:
Environment Variable
Result
Description
res_app_gitRepo_pathuser1/repo1
Returns the
pathattribute of theapp_gitReporesourceres_app_gitRepo_gitProvider_urlReturns
urlof the Git Provider of theapp_gitReporesourceThen the following environment variables will be available to a step that uses the
app_gitReporesource as an input:Environment Variables
steps: - name: build_app type: MvnBuild configuration: sourceLocation: . mvnCommand: clean install configFileLocation: . inputResources: - name: app_gitRepo # Use the app_gitRepo resource execution: onSuccess: - send_notification notifySlack --text "Maven build completed for $res_app_gitRepo_path at $res_app_gitRepo_gitProvider_url" onFailure: - send_notification notifySlack --text "Maven build FAILED for $res_app_gitRepo_path at $res_app_gitRepo_gitProvider_url"
Using Arrays
Certain resources, such as Aql, DistributionRule, and VmCluster have arrays in their configuration.
For arrays within resources ( VmCluster):
res_<resource name>_<array heading>_len (this tells you how many entries in array)
res_<resource name>_<array heading>_0
res_<resource name>_<array heading>_1
res_<resource name>_<array heading>_2
For object arrays within resources ( DistributionRule):
res_<resource name>_<array heading>_len (this tells you how many entries in array)
res_<resource name>_<array heading>_0_<tag>
res_<resource name>_<array heading>_1_<tag>