Setting Teamcity version number with counter from

2019-04-11 07:46发布

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> 

1条回答
Evening l夕情丶
2楼-- · 2019-04-11 08:23

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}

查看更多
登录 后发表回答