TeamCity的 - 的版本号每周自动增量 [英] Teamcity - automatic weekly incrementation of build number

查看:550
本文介绍了TeamCity的 - 的版本号每周自动增量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有任何暗示它是如何可能递增每周下面(249)的数量的第二部分? TeamCity的是能够增加后,每建设构建柜台数量,到目前为止,一切顺利。

1.0 249 %build.counter%

此外,我需要自动增加每周249个。
如:249> 250; 250> 251; 101> 102; 41> 42; ...

先谢谢了。


解决方案

您可以通过编程方式实现这一目标,重新界定在PowerShell中生成步骤 build.number


  1. 添加一个PowerShell构建步骤为您的配置的第一步。

  2. 设置在构建步骤如下参数:

    • 剧本来源$ 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.

  1. Add a PowerShell build step as the first step in your configuration.
  2. Set the following parameters in that build step:
    • Script: Source Code
    • Script execution mode: Execute .ps1 script with "File" argument
    • Script 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屋!

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