3

I'm currently trying to update the version no. in TeamCity using a Nant build file, containing the version number. If I just use

<property name="versionNo" value="2.16.3."/>
.
.
<echo message="##teamcity[buildNumber '${versionNo}']"></echo> 

In the script the buildNumber is update to 2.16.3 but I would also like to have the counter on this version number. Meaning I would like to have

<echo message="##teamcity[buildNumber '${versionNo}.{0}']"></echo> 

But this doesn't work. Does anybody know how to do this, tried many things among this solution http://binary-notes.blogspot.com/2011/05/controlling-application-version-number.html however, the ${Version} parameter is a clue for me ?

Update

Made the implementation by using {0} as buildnumber in Teamcity and appending that build number to my own build number in the file

<property name="versionNo" value="2.16.3."/>
.
.
<echo message="##teamcity[buildNumber '${versionNo}.${environment::get-variable('BUILD_NUMBER')}']"></echo> 
dennis_ler
  • 659
  • 1
  • 9
  • 36

1 Answers1

7

TeamCity has a build number which it places into the environment while running your build script.

You can access the environment variable BUILD_NUMBER and append it to your actual version number. Then echo it back to TeamCity. I assume this would be available via ${sys.env.BUILD_NUMBER}.

So perhaps:

<echo message="##teamcity[buildNumber '${versionNo}.${sys.env.BUILD_NUMBER}']"></echo> 

PS. There really is no reason to change the build number in teamcity like they do in that article. You can leave it {0}

sylvanaar
  • 8,096
  • 37
  • 59
  • 2
    Cool thx, that helped. What I did was – dennis_ler Jan 18 '12 at 11:59
  • Cross reference; http://stackoverflow.com/questions/6831884/teamcitys-assemblyinfo-patchers-number-format – AnneTheAgile Aug 13 '12 at 18:04
  • Documentation for the feature in TeamCity is [here](https://confluence.jetbrains.com/display/TCD9/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-ReportingBuildNumber), including how to get the current build counter value. – Hank Schultz Jun 24 '15 at 13:09