传递版本以发布 [英] Pass Build Version to Release

查看:72
本文介绍了传递版本以发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将构建版本(例如v 1.2.3)从Azure DevOps构建管道传递到工件,或通过工件传递到发行版?理想情况下,我们希望我们的内部版本号(在package.json中)与发行版本名称相匹配,或者更确切地说,我们的发行版本名称应反映内部版本号/语义版本.

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.

在创建发行版时输入版本号的手动解决方案也是可以接受的.该发行版的发行版名称格式设置为Parts-$(Build.Buildnumber).我们在这里看不到使用自定义值(在创建发行版时输入)的方法. 文档不清楚如何使用这些变量.

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. 使用##vso[]指令从构建脚本中动态设置构建名称,如下所示(在本例中,是从package.json中读取version:
  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. 在发行版本发行名称格式"中使用$(Build.Buildnumber).

这篇关于传递版本以发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆