问题
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.
回答1:
OK, I discovered the answer.
- Set the build name dynamically from your build script using the
##vso[]
directive as follows (in our case by readiningversion
frompackage.json
:
$ver = (Get-Content -Raw ./package.json | ConvertFrom-Json).version
Write-Host "##vso[build.updatebuildnumber]$ver"
- Use
$(Build.Buildnumber)
in your release pipelines "Release name format".
来源:https://stackoverflow.com/questions/62176262/pass-build-version-to-release