在 TFS build +1 中增加变量值
Increment variable value in TFS build +1
我有一个带有预定义变量 $(ProjectBuildNumber) 的 Microsoft Visual Studio Team Foundation Server(版本 15.117.26714.0)。
有没有办法在构建过程中将具有次要构建号的变量值增加 +1?
$(ProjectBuildNumber) = 663
因此,在下一个版本中它将是:
$(ProjectBuildNumber) = 664
您不能在构建定义的构建号中引用变量。但是您可以做的是覆盖构建本身的构建号。您可以使用神奇的日志命令或使用我的 VSTS Variables Task to set the Build.BuildNumber in the build itself。变量任务确实扩展了变量引用。您可能只将该值设置为当前值以使其展开。
要自己发出日志命令,请使用批处理脚本、PowerShell 或 bash 将以下特定字符串输出到控制台:
##vso[build.updatebuildnumber]build number
Update build number for current build. Example:
##vso[build.updatebuildnumber]my-new-build-number
Minimum agent version: 1.88
source: 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:
这些东西加起来应该可以得到你想要的。
在变量部分,
set the value of ProjectBuildNumber to $[counter('', 663)].
这将从 663 作为 ProjectBuildNumber 开始对构建进行排队,并为后续构建队列递增 1。
我有一个带有预定义变量 $(ProjectBuildNumber) 的 Microsoft Visual Studio Team Foundation Server(版本 15.117.26714.0)。
有没有办法在构建过程中将具有次要构建号的变量值增加 +1?
$(ProjectBuildNumber) = 663
因此,在下一个版本中它将是:
$(ProjectBuildNumber) = 664
您不能在构建定义的构建号中引用变量。但是您可以做的是覆盖构建本身的构建号。您可以使用神奇的日志命令或使用我的 VSTS Variables Task to set the Build.BuildNumber in the build itself。变量任务确实扩展了变量引用。您可能只将该值设置为当前值以使其展开。
要自己发出日志命令,请使用批处理脚本、PowerShell 或 bash 将以下特定字符串输出到控制台:
##vso[build.updatebuildnumber]build number
Update build number for current build. Example:
##vso[build.updatebuildnumber]my-new-build-number
Minimum agent version: 1.88
source: 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:
这些东西加起来应该可以得到你想要的。
在变量部分,
set the value of ProjectBuildNumber to $[counter('', 663)].
这将从 663 作为 ProjectBuildNumber 开始对构建进行排队,并为后续构建队列递增 1。