Teamcity: build label UI not updating when updating variable in a script


I am putting together a teamcity build where I want to set the build label after reading it from a configuration file.

ie I want to set this...

So I have set the following...

And then just set this to a default value, until the running script updates it

Now in a build set, I update this env variable using

"##teamcity[setParameter name='env.build_version' value='$version']"

In the next build set I print out this variable, and I see it IS successfully updated.

However, in the UI it just stays at the default value, rather than updating when I update this variable. I have looked at but this did not work for me .

My question is, how can I get the UI to be updated when I set this variable (or do I need to do this some other way)?

Thanks in advance for any help



I think the cause is that TeamCity only reads your environment variable once upon starting the build (that is normal). To resolve this, after changing the value of the environment variable, you also need to report the new build number to TeamCity using the ##teamcity[buildNumber '...'] service message.

As a side note, if the env.build_version parameter is not used for anything else but changing the build number, you can probably even skip using it altogether and replace

"##teamcity[setParameter name='env.build_version' value='$version']"


"##teamcity[buildNumber '$version']"

I hope this helps!



Hi thankyou for that. I had tried the above, and it didn't initially work, but I found I had the outer quotes missing. . I added these and now it works. Thankyou


Please sign in to leave a comment.