TeamCity的 - 的版本号每周自动增量 [英] Teamcity - automatic weekly incrementation of build number
问题描述
有任何暗示它是如何可能递增每周下面(249)的数量的第二部分? TeamCity的是能够增加后,每建设构建柜台数量,到目前为止,一切顺利。
1.0 249 的%build.counter%
此外,我需要自动增加每周249个。
如:249> 250; 250> 251; 101> 102; 41> 42; ...
先谢谢了。
您可以通过编程方式实现这一目标,重新界定在PowerShell中生成步骤 build.number
。
- 添加一个PowerShell构建步骤为您的配置的第一步。
- 设置在构建步骤如下参数:
-
剧本
:来源$ C $ C 的 -
脚本执行模式
:执行的.ps1脚本文件的说法的 -
脚本源
:
-
写主机## TeamCity的[buildNumber'1.0。$([数学] ::楼([日期时间] :: Now.DayOfYear / 7))%build.counter%']
所有的后续构建步骤应该可以使用新的 build.number
值。
的 $([数学] ::楼([日期时间] :: Now.DayOfYear / 7))
是神奇的;它产生的一年中的当前星期。你需要按摩这一点,以符合现有的编号。
关于重用的说明:您会想为了重复使用多个项目,这个步骤来参数 1.0
主要/次要值。我定义了一个参数,%MAJOR.MINOR%
,并设置其为1.0的值,那么PowerShell脚本会是这样(或其他):
写主机## TeamCity的[buildNumber'%MAJOR.MINOR%。$([数学] ::楼([日期时间] :: Now.DayOfYear / 7))%build.counter%' ]
编辑:切换到简单的写主机
实施由雅各布提到
has anybody a hint how it is possible to increment a second part of the number below ("249") on weekly basis? TeamCity is able to increase after every build the number of the build counter, so far so good.
1.0.249.%build.counter%
Additionally I need to increase the 249 on weekly basis automatically. eg.: 249 > 250; 250 > 251; 101 > 102; 41 > 42;...
Thanks in advance.
You can accomplish this by programatically re-defining the build.number
in a PowerShell build step.
- Add a PowerShell build step as the first step in your configuration.
- Set the following parameters in that build step:
Script
: Source CodeScript execution mode
: Execute .ps1 script with "File" argumentScript source
:
Write-Host "##teamcity[buildNumber '1.0.$([Math]::Floor([DateTime]::Now.DayOfYear/7)).%build.counter%']"
All subsequent build steps should be able to use the new build.number
value.
The $([Math]::Floor([DateTime]::Now.DayOfYear/7))
is the magic; it produces the current week of the year. You'll need to massage this a little bit to conform to your existing numbering.
A note about reuse: You'll want to parameterize the 1.0
major/minor value in order to reuse this step across multiple projects. I'd define a parameter, %major.minor%
, and set its value to 1.0 (or whatever.) The PowerShell script would then be this:
Write-Host "##teamcity[buildNumber '%major.minor%.$([Math]::Floor([DateTime]::Now.DayOfYear/7)).%build.counter%']"
Edit: Switched to a simpler Write-Host
implementation as mentioned by Jacob.
这篇关于TeamCity的 - 的版本号每周自动增量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!