在TFS内部增加变量值+1

问题描述 投票:10回答:2

我有一个带有预定义变量$(ProjectBuildNumber)的Microsoft Visual Studio Team Foundation Server(版本15.117.26714.0)。

在构建过程中,是否有任何方法可以将带有次要内部编号的变量值增加+1?

$(ProjectBuildNumber)  =   663

那么,在下一次构建时,它将是:

$(ProjectBuildNumber)  =   664

enter image description here

enter image description here

tfs azure-devops azure-pipelines azure-pipelines-build-task
2个回答
7
投票

您无法在构建定义的构建号中引用变量。但是你可以做的是覆盖构建本身的构建号。您可以使用魔术日志命令或使用我的VSTS Variables Task to set the Build.BuildNumber in the build itself。变量任务确实扩展了变量引用。您可以将值设置为当前值以使其扩展。

enter image description here

要自己发出log命令,请使用批处理脚本PowerShell或bash将以下特定字符串输出到控制台:

## vso [build.updatebuildnumber]内部版本号

更新当前版本的内部版本号。例:

##vso[build.updatebuildnumber]my-new-build-number

最低代理商版本:1.88

来源:https://github.com/Microsoft/vsts-tasks/blob/master/docs/authoring/commands.md

另一种选择是使用$(Rev)选项:

Build.BuildNumber = 1.1.$(Rev:.r)  

每次构建运行时,这将自动增加变量。

update a variable in a Build Definition use yet another extension

enter image description here

这些东西组合应该能够得到你想要的东西。


0
投票

在变量部分,

将ProjectBuildNumber的值设置为$ [counter('',663)]。

这将队列构建从663开始作为ProjectBuildNumber,并为后续构建队列增加1。

© www.soinside.com 2019 - 2024. All rights reserved.