Teamcity, set configuration parameter for next build

﹥>﹥吖頭↗ 提交于 2019-12-07 10:29:16

问题


I'm trying to set/change a build parameter from build 1 to be used in build 2.

In build 1 I have a build step that sets a configuration parameter like this:

echo "##teamcity[setParameter name='ENVIRONMENT' value='%Target environment%']"

And in a build step on build 2, I want to use this environment variable in a rake task by specifying %ENVIRONMENT%

The problem I have is that the configuration parameter is not visible in build 2. I have surely missed something essential.

I have also tried with env variables but that seems like the wrong approach as this is just configuration variables which is not needed in a build script.

Any clues?

Thanks


回答1:


You can publish an artifact with the value you want in build 1, introduce an artifact dependency from build 2 to build 1, and in the first step of build 2 transform that artifact into a configuration value again for the other steps in build 2 by using the echo (or better Write-Host) statement you mentioned.




回答2:


You can solve this in the same way I did for: Is it possible to permanently update the value of a TeamCity build parameter as a result of a custom run?

Build 1 can update a variable which is being used in build 2 rather than build 2 trying to read a parameter in build 1.

Download and install CURL on build agent:

Add a command line step to build 1:

curl -v --request PUT -d "%Target environment%" --Header "Content-Type: text/plain" http://username:password@servername:8080/httpAuth/app/rest/projects/Build2Project/parameters/ENVIRONMENT

This updates the value of a parameter on a project, but you can use the REST API to update it on a particular build configuration if you prefer.

All REST.API documentation for TeamCity v8 can be found on their website




回答3:


You can reference MyVariable variable which you set in Build configuration 1 in a script in Build configuration X such way: %dep.BuildConfiguration1Id.MyVariable%



来源:https://stackoverflow.com/questions/23495661/teamcity-set-configuration-parameter-for-next-build

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!