Teamcity SetParameter doesn't seem to be working

删除回忆录丶 提交于 2019-12-03 16:58:12

问题


As the first step in a build configuration I am trying to dynamically change a parameter and use it in the subsequent steps. Reading online, it seems that the way to do this is to call ##teamcity[setParameter. But this doesn't seem to be working. It doesn't even change the value in the same step.

For example, I have created a test parameter and set it's default value to '1'. Inside a powershell script, I tried to change it to 2, as shown below.

But the output remains unchanged as can be seen below

I am currently using TeamCity 8.0.3 (build 27540). What am I doing wrong?


回答1:


EDIT: I think the problem might be the command you're using to set the parameter. Try:

Write-Host "##teamcity[setParameter name='TestParameter' value='2']"

--

We've experienced the same behavior. The key here is 'subsequent steps.' You must modify the parameter in a separate build step that is run before the step in which you want to use the new parameter.

It's my understanding that all parameters in a build step are evaluated immediately before the execution of that step. The tokens will be replaced with the unmodified values of those parameters. Thus, what actually gets executed by the build agent is:

Write-Host "TestParameter value is 1"
Write-Host "##teamcity[setParameter name='TestParameter' value='2']"
Write-Host "TestParameter value is 1"


来源:https://stackoverflow.com/questions/22141259/teamcity-setparameter-doesnt-seem-to-be-working

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