是否可以通过自定义运行永久更新构建参数的值?
例如,考虑一个配置为具有内部版本号格式的版本:%Major%.%Minor%.%Patch%.%build.counter%
Major,Minor和Patch,在构建配置中定义为具有特定值.为了举个例子,假设这给出了3.1.2.36的内部版本号.
可以通过单击运行旁边的"..."更改构建号,然后更改其中一个参数的值.从1-> 2更改Minor并从2-> 0更改将使下一个版本的编号为3.2.0.37.
我并不过分担心37没有被重置为0,但问题是被触发的下一个构建(不是自定义运行的结果)将具有内部编号3.1.2.38,这是一个较低的数字.是否有可能在运行自定义构建并更改新值保持的数字时?
我正在寻找一种没有TeamCity管理员权限的用户可以根据他们所做的更改来增加版本号的方法.
我们正在运行v8.1.2(build 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
Run Code Online (Sandbox Code Playgroud)
这会增加指定的内部版本号,并将下游版本部件重置为0.
例如,3.2.12.122上的次要版本增加到3.3.0.0.
注意 - 在我上面的特定示例中,构建计数器在依赖构建上重置,而不是正在运行的配置.这可能是也可能不是你所追求的.更换
%dep.Dependant_BuildName.system.teamcity.buildType.id%
同
%system.teamcity.buildType.id%
如果要重置当前正在运行的构建配置.
归档时间: |
|
查看次数: |
2709 次 |
最近记录: |