I'm building a docker image and use the BuildNumber
as the image tag.
Later, on my release pipeline, I want to get this value and use it in azure cli
task.
I know about Build.TriggeredBy.BuildNumber
variable but the release might be triggered manually and I want it to use the buildNumber from the build task.
I thought about writing the value to a file and pack it into an artifact, but I can't see how to use it in the release pipeline.
1 Answers
A release pipeline must be associated to an artifacts from a build pipeline. You can directly use the buildNumber of the build with $(Build.BuildNumber) in your release pipeline.
Please refer to the release variables. No matter your release pipeline is auto-triggered or manually triggered. It can always get the build number from the attached artifacts.
You can also define a variable group in the Library section and linked the group to your build and release pipeline, which allow build and release pipeline access to the same variable. make sure allow access to all pipeline is enabled. You can use the predefined variables as shown in below pic. . And link the variable group in your pipeline
For more information about variable group. Please refer to Microsoft document
If above are not what you are looking for. These two tasks (Variable Save Task, Variable Load Task) may be helpful. Check this thread for details.