首页 > 解决方案 > 如何在 Azure DevOps 中将项目版本显示为发布名称

问题描述

我有发布版本pom.xml。例如,xyz-0.0.1是我的pom.xml. Azure Build 创建包。

我想在发布管道中使用版本xyz-0.0.1作为发布名称。如何将版本传递给发布管道并在选项中设置“发布名称格式”?

在此处输入图像描述

标签: azure-devopsazure-pipelines

解决方案


因为版本在文件(pom.xml)中,所以不能将版本放在“版本名称格式”中,需要在发布期间从文件中提取版本并分配版本号。

您可以使用 PowerShell 脚本来完成(我编写了这个概念,您需要了解如何准确获取 xml 节点):

$file = Get-Content th/to/pom.xml
# Read the version with something like this:
# $version = Select-Xml -Content $file -XPath "//version"
# Then update the Release name:
Write-Host "##vso[release.updatereleasename]$version"

在此处输入图像描述


推荐阅读