I have a pipeline yaml that is triggered based on the completion of another pipeline. I want to access the properties of the trigger resource to get the runName/buildNumber and use it as a variable in the second pipeline. How can I do this?
The pipeline yaml has the following format:
resources:
pipelines:
- pipeline: OfficialReleaseBuild
source: Release-Official
trigger:
branches:
include:
- release/*
tags:
- weeklyRelease
This is working fine, and it is triggering this pipeline whenever a build from the Release-Official pipeline with the 'weeklyRelease' tagcompletes
However, since this pipeline can be triggered manually or automatically, there is variable that I want to set based on the properties that are available from the ResourceTrigger:
variables:
# package version to publish
- name: version
${{ if eq( variables['resources.triggeringAlias'], 'OfficialReleaseBuild' ) }}:
value: variables['resources.pipeline.OfficialReleaseBuild.runName']
${{ else }}:
value: "${{ parameters.packageVersion }}"
However, it is not working. Is there anything I am missing? It's always defaulting to parameters.packageVersion. How can I access the properties from the resource trigger?
This is because
${{ if eq( variables['resources.triggeringAlias'], 'OfficialReleaseBuild' ) }}:expression is processed at compile moment butresources.triggeringAliasis a run-time variable. You may use the logging command: SetVariable: Initialize or modify the value of a variable