作为自定义运行的结果,是否可以永久更新 TeamCity 构建参数的值? [英] Is it possible to permanently update the value of a TeamCity build parameter as a result of a custom run?

查看:39
本文介绍了作为自定义运行的结果,是否可以永久更新 TeamCity 构建参数的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以作为自定义运行的结果永久更新构建参数的值?

Is it possible to permanently update the value of a build parameter as a result of a custom run?

例如,考虑一个配置为具有构建号格式的构建:%Major%.%Minor%.%Patch%.%build.counter%

For example, consider a build which is configured to have the build number format: %Major%.%Minor%.%Patch%.%build.counter%

Major、Minor 和 Patch 并在构建配置中定义为具有某些值.举个例子,假设这给出了 3.1.2.36 的内部版本号.

Major, Minor and Patch and defined in the build configuration to have certain values. For the sake of an example, lets say this gives a build number of 3.1.2.36.

可以通过单击运行旁边的..."来更改内部版本号,然后更改其中一个参数的值.将 Minor 从 1->2 和补丁从 2->0 更改为下一个构建编号为 3.2.0.37.

It is possible to change the build number by clicking '...' next to run and then changing the value of one of the params. Changing Minor from 1->2 and patch from 2->0 would give the next build the number 3.2.0.37.

我并不过分担心 37 尚未重置为 0,但问题是触发的下一个构建(不是自定义运行的结果)将具有构建号 3.1.2.38,即一个较低的数字.当您运行自定义构建并更改新值保留的数字时,是否有可能?

I'm not overly concerned that 37 hasn't be reset to 0, but the problem is that the next build which is triggered (not as a result of a custom run) will have the build number 3.1.2.38 which is a lower number. Is it possible that when you run a custom build and change the numbers that the new values are persisted?

我正在寻找一种方法,让没有 TeamCity 管理员权限的用户可以根据他们所做的更改增加版本号.

I am looking for a way that users with no TeamCity admin rights can cause the version number to be incremented according to the changes they have made.

我们正在运行 v8.1.2(内部版本 29993).

We are running v8.1.2 (build 29993).

推荐答案

为了解决这个问题,我使用了 TeamCity REST API.我创建了一个名为ReleaseType"的提示类型的新构建参数,它可以是 Patch、Minor 或 Major.然后在此命令行脚本中使用它,该脚本设置为 TeamCity 构建步骤:

To fix the issue I used the TeamCity REST API. I created a new build param of type prompt called 'ReleaseType' which can be either Patch, Minor or Major. This is then used in this command line script which is set up as a TeamCity build step:

IF "%ReleaseType%"=="Major" (
set /a newVersion=%VersionMajor%+1
curl -v --request PUT -d 0 --Header "Content-Type: text/plain" http://username:password@servername:8080/httpAuth/app/rest/projects/%system.teamcity.projectName%/parameters/VersionMinor
curl -v --request PUT -d 0 --Header "Content-Type: text/plain" http://username:password@servername:8080/httpAuth/app/rest/projects/%system.teamcity.projectName%/parameters/VersionPatch
)

IF "%ReleaseType%"=="Minor" (
set /a newVersion=%VersionMinor%+1
curl -v --request PUT -d 0 --Header "Content-Type: text/plain" http://username:password@servername:8080/httpAuth/app/rest/projects/%system.teamcity.projectName%/parameters/VersionPatch
)

IF "%ReleaseType%"=="Patch" (
set /a newVersion=%VersionPatch%+1
)

curl -v --request PUT -d %%newVersion%% --Header "Content-Type: text/plain" http://username:password@servername:8080/httpAuth/app/rest/projects/%system.teamcity.projectName%/parameters/Version%ReleaseType%
curl -v --request PUT -d 0 --Header "Content-Type: text/plain" http://username:password@servername:8080/httpAuth/app/rest/buildTypes/id:%dep.Dependant_BuildName.system.teamcity.buildType.id%/settings/buildNumberCounter

这会增加指定的内部版本号并将下游版本部分重置为 0.

This increments the specified build number and resets downstream version parts to 0.

例如,3.2.12.122 上的次要版本增加到 3.3.0.0.

For example, a minor version increase on 3.2.12.122 goes to 3.3.0.0.

注意 - 在我上面的特定示例中,构建计数器在依赖构建而不是正在运行的配置上重置.这可能是也可能不是您所追求的.替换

Note - in my particular example above the build counter is reset on a dependant build and not the configuration which is running. This may or may not be what you are after. Replace

%dep.Dependant_BuildName.system.teamcity.buildType.id%

%dep.Dependant_BuildName.system.teamcity.buildType.id%

%system.teamcity.buildType.id%

%system.teamcity.buildType.id%

如果您想重置当前正在运行的构建配置.

if you want to reset the current running build configuration.

这篇关于作为自定义运行的结果,是否可以永久更新 TeamCity 构建参数的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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