Reputation: 14269
How does one pass the build version (say v1.2.3
) from an Azure DevOps Build Pipeline to/through the Artifact to the Release? Ideally we would like our build number (in package.json) to match the release name or rather our release name should reflect the build number/semantic version.
A manual solution where we enter the version number when creating the release is also acceptable. The release has a Release Name format which is set to Parts-$(Build.Buildnumber)
. We can see no way to use custom values (entered at release creation) here. The documentation is unclear on how to use these variables.
Upvotes: 1
Views: 2119
Reputation: 107
In your yml file declare a variable like so,
variables:
DBCR: $[replace(variables['build.sourceversionmessage'], '/', '-')]
after which you can create a custom build number in your yaml like so,
name: $(DBCR)_v$(Rev:r)
and then use $(Build.Buildnumber) in your release pipelines "Release name format".
Simple and effective :)
Upvotes: 0
Reputation: 14269
OK, I discovered the answer.
##vso[]
directive as follows (in our case by readining version
from package.json
:$ver = (Get-Content -Raw ./package.json | ConvertFrom-Json).version
Write-Host "##vso[build.updatebuildnumber]$ver"
$(Build.Buildnumber)
in your release pipelines "Release name format".Upvotes: 3