Build Teamcity-每周自动增加构建数量
有没有人能告诉我们,如何每周增加下面数字的第二部分(“249”)呢?TeamCity能够在每次构建后增加构建计数器的数量,到目前为止效果良好 1.0.249%build.counter% 此外,我需要每周自动增加249。 例:249>250;250 > 251; 101 > 102; 41 > 42;...Build Teamcity-每周自动增加构建数量,build,version,teamcity,versioning,Build,Version,Teamcity,Versioning,有没有人能告诉我们,如何每周增加下面数字的第二部分(“249”)呢?TeamCity能够在每次构建后增加构建计数器的数量,到目前为止效果良好 1.0.249%build.counter% 此外,我需要每周自动增加249。 例:249>250;250 > 251; 101 > 102; 41 > 42;... 提前感谢。您可以通过在PowerShell构建步骤中以编程方式重新定义build.number来实现这一点 添加PowerShell构建步骤作为配置中的第一步 在该生成步骤中设置以下参数:
提前感谢。您可以通过在PowerShell构建步骤中以编程方式重新定义
build.number
来实现这一点
:源代码脚本
:使用“File”参数执行.ps1脚本脚本执行模式
:脚本源代码
编辑:切换到Jacob提到的更简单的
写主机实现。您可以通过编程方式在PowerShell构建步骤中重新定义构建.number
来完成此操作
添加PowerShell构建步骤作为配置中的第一步
在该生成步骤中设置以下参数:
脚本
:源代码
脚本执行模式
:使用“File”参数执行.ps1脚本
脚本源代码
:
编辑:切换到Jacob提到的更简单的写主机实现。在TeamCity中搜索自定义版本号的方法时,我偶然发现了这个问题。@john hoerr提供的答案非常有效(谢谢)
我已经采纳了约翰的答案,并根据我的需要修改了它。下面是一个powershell脚本,它将使用生成配置设置的“常规”选项卡中提供的生成编号格式、日期格式(任何性质)和TeamCity的生成计数器更新生成编号:
# The build number format is YYDDD.BB
# YY is the last two digits of the year
# DDD is the day number in the year (1-365)
# BB is the build number of the day for this build type (1-N)
# Get the build number from TeamCity. This will contain whatever is placed
# into the build number portion of the build definition
$TeamCityBuildNumber = "%build.number%"
# Get the build counter from TeamCity and ensure it's in the format 00 (for sorting).
# Assumption: there are less than 100 builds a day for this build definition.
$TeamCityBuildCounter = "%build.counter%".PadLeft(2, "0")
# The build number really just contains the date portion of the whole build number string. I am tweaking it to also contain a branch name but have removed this from my example code for simplicity purposes.
$BuildNumber = ([string]::Concat(([DateTime]::Now.Date.Year - 2000),([DateTime]::Now.DayOfYear)))
# Write the build number to the host, effectively altering the build number
# within the process space of the build.
Write-Host "##teamcity[buildNumber '$TeamCityBuildNumber.$BuildNumber.$TeamCityBuildCounter']"
理想情况下,构建计数器在午夜重置为0,以便当天的第一个构建收到1的构建计数器值。在TeamCity中搜索自定义构建编号的方法时,我碰巧遇到了这个问题。@john hoerr提供的答案非常有效(谢谢)
我已经采纳了约翰的答案,并根据我的需要修改了它。下面是一个powershell脚本,它将使用生成配置设置的“常规”选项卡中提供的生成编号格式、日期格式(任何性质)和TeamCity的生成计数器更新生成编号:
# The build number format is YYDDD.BB
# YY is the last two digits of the year
# DDD is the day number in the year (1-365)
# BB is the build number of the day for this build type (1-N)
# Get the build number from TeamCity. This will contain whatever is placed
# into the build number portion of the build definition
$TeamCityBuildNumber = "%build.number%"
# Get the build counter from TeamCity and ensure it's in the format 00 (for sorting).
# Assumption: there are less than 100 builds a day for this build definition.
$TeamCityBuildCounter = "%build.counter%".PadLeft(2, "0")
# The build number really just contains the date portion of the whole build number string. I am tweaking it to also contain a branch name but have removed this from my example code for simplicity purposes.
$BuildNumber = ([string]::Concat(([DateTime]::Now.Date.Year - 2000),([DateTime]::Now.DayOfYear)))
# Write the build number to the host, effectively altering the build number
# within the process space of the build.
Write-Host "##teamcity[buildNumber '$TeamCityBuildNumber.$BuildNumber.$TeamCityBuildCounter']"
理想情况下,构建计数器会在午夜重置为0,以便当天的第一个构建收到的构建计数器值为1。我希望这也能起作用,但无法使其起作用。我决定查看一下的源代码,注意到它们使用了不同的语法:Write Host“##teamcity[buildNumber'$buildNumber']”
我切换到了该格式,并且工作正常,因此它可能因teamcity版本而异。还要注意的是,设置buildNumber这似乎不适用于AssemblyInfo,因为它在构建的早期就完成了它的工作。我正在寻找一种解决方案,以在程序集中获得创建的版本号。现在,它使用assemblyinfopatcher步骤添加buildnumber,在我的buildsteps中,我使用创建的编号更新版本号。但正如您所提到的,该步骤在assemblyinfopatcher步骤之后运行。您是否设法解决了这个问题?这里提供了关于“与TC对话”这一巧妙功能的文档:我希望它也能正常工作,但无法正常工作。我决定查看一下的源代码,注意到它们使用了不同的语法:Write Host“##teamcity[buildNumber'$buildNumber']”
我切换到了该格式,并且工作正常,因此它可能因teamcity版本而异。还要注意的是,设置buildNumber这似乎不适用于AssemblyInfo,因为它在构建的早期就完成了它的工作。我正在寻找一种解决方案,以在程序集中获得创建的版本号。现在,它使用assemblyinfopatcher步骤添加buildnumber,在我的buildsteps中,我使用创建的编号更新版本号。但正如您所提到的,该步骤在assemblyinfopatcher步骤之后运行。您是否设法解决了这个问题?关于“与TC对话”这一巧妙功能的文档如下:如何将生成计数器重置为每晚1个?如何将生成计数器重置为每晚1个?
# The build number format is YYDDD.BB
# YY is the last two digits of the year
# DDD is the day number in the year (1-365)
# BB is the build number of the day for this build type (1-N)
# Get the build number from TeamCity. This will contain whatever is placed
# into the build number portion of the build definition
$TeamCityBuildNumber = "%build.number%"
# Get the build counter from TeamCity and ensure it's in the format 00 (for sorting).
# Assumption: there are less than 100 builds a day for this build definition.
$TeamCityBuildCounter = "%build.counter%".PadLeft(2, "0")
# The build number really just contains the date portion of the whole build number string. I am tweaking it to also contain a branch name but have removed this from my example code for simplicity purposes.
$BuildNumber = ([string]::Concat(([DateTime]::Now.Date.Year - 2000),([DateTime]::Now.DayOfYear)))
# Write the build number to the host, effectively altering the build number
# within the process space of the build.
Write-Host "##teamcity[buildNumber '$TeamCityBuildNumber.$BuildNumber.$TeamCityBuildCounter']"