Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Teamcity SetParameter doesn't seem to be working

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.

enter image description here

But the output remains unchanged as can be seen below

enter image description here

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

like image 779
Chaitanya Avatar asked Mar 03 '14 07:03

Chaitanya


1 Answers

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"
like image 97
John Hoerr Avatar answered Sep 29 '22 22:09

John Hoerr