1
votes

In my build pipeline, I use a value of $(Build.BuildNumber) variable as an image tag for docker images and then push images to ACR with these tags:

$ImageTagVar = $(Build.BuildNumber)
Write-Host "Set environment variable to $ImageTagVar"
Write-Host "##vso[task.setvariable variable=ImageTag]$ImageTagVar"
"##vso[task.setvariable variable=ImageTag]$ImageTagVar"

Now I need to get the value of $(ImageTag) variable (or $(Build.BuildNumber)) from build pipeline into release pipeline. How this can be done?

1

1 Answers

1
votes

You can use the same variable Build.BuildNumber in the release pipeline, the value will be the build number of the primary artifacts build.

From the docs:

For each artifact that is referenced in a release, you can use the following artifact variables. Not all variables are meaningful for each artifact type. The table below lists the default artifact variables and provides examples of the values that they have depending on the artifact type. If an example is empty, it implies that the variable is not populated for that artifact type.

Replace {alias} with the value you specified for the artifact alias, or with the default value generated for the release pipeline.

You designate one of the artifacts as a primary artifact in a release pipeline. For the designated primary artifact, Azure Pipelines populates the following variables.

Build.BuildNumber - same as - Release.Artifacts.{Primary artifact alias}.BuildNumber