Pass Build Version to Release

半城伤御伤魂 提交于 2020-06-17 13:17:30

问题


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.

  1. Set the build name dynamically from your build script using the ##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"
  1. Use $(Build.Buildnumber) in your release pipelines "Release name format".


来源:https://stackoverflow.com/questions/62176262/pass-build-version-to-release

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!