I am trying to use the new multistage yaml pipelines to download an artifact from a specific build. The DownloadBuildArtifacts@0
task has an output variable for BuildNumber
that I would like to reference further on, but I can't figure out how to access it.
In the GUI for the task there is a box that let's you set a reference name
But from the yaml pipeline definition I can't figure out how access this variable.
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'specific'
project: 'Sandbox'
pipeline: 'bash-testing'
buildVersionToDownload: 'latest'
downloadType: 'single'
artifactName: 'someArtifactName'
referenceNames: 'blahblah'
- bash: echo $BLAHBLAH_BUILDNUMBER
Simply outputs
You set an incorrect output variable defined.
The format of define an output variable in previous task in YAML:
echo "##vso[task.setvariable variable=myOutputVar;isOutput=true]this is the value of output variable"
name: PWS
Note: isOutput=true
is the key code which announce this variable is an output variable. And also, name
is equals to Reference name
which displayed in Classic editor UI.
For how to access and use this output variable in Bash task, the format of this call script is:
echo $(name.VariableName)
So, for my sample script is:
echo $(PWS.myOutputVar)
My yaml was incorrect and Merlin Liang's comment about name
being the right syntax helped me figure it out.
The correct yaml syntax needed to reference a task output variable is.
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'specific'
project: 'Sandbox'
pipeline: 'bash-testing'
buildVersionToDownload: 'latest'
downloadType: 'single'
artifactName: 'some-artifact-name'
name: 'TEST'
- bash: echo $(TEST.BuildNumber)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With