gpt4 book ai didi

teamcity - 是否可以因自定义运行而永久更新 TeamCity 构建参数的值?

转载 作者:行者123 更新时间:2023-12-02 21:46:47 24 4
gpt4 key购买 nike

是否可以通过自定义运行永久更新构建参数的值?

例如,考虑一个配置为具有内部版本号格式的内部版本:%主要%.%次要%.%补丁%.%build.counter%

Major、Minor 和 Patch 并在构建配置中定义为具有特定值。举个例子,假设构建号为 3.1.2.36。

可以通过单击运行旁边的“...”来更改内部版本号,然后更改其中一个参数的值。将 Minor 从 1->2 更改并将 patch 从 2->0 更改将为下一个版本提供编号 3.2.0.37。

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

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

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

最佳答案

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

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。

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

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

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

%system.teamcity.buildType.id%

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

关于teamcity - 是否可以因自定义运行而永久更新 TeamCity 构建参数的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23339074/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com