I am new to ant and TeamCity, but my team has been using it a little. We can’t seem to figure out this issue with customizing the build number.
We want the build number to be formatted: b.<year><month><day>
, for example: b.20240606
.
I have found that I can set parameters’ values in my build.xml
file:
<property name="build.num" value="b.${current.date}" />
<property name="build.number" value="${build.num}" />
I am using these values to set the values for TeamCity; I have tried each of these without success:
<echo message="##teamcity[setParameter name='env.BUILD_DATE' value='${current.date}']" />
<echo message="##teamcity[setParameter name='env.BUILD_NUMBER' value='${build.num}']" />
<echo message="##teamcity[setParameter name='build.number' value='${build.num}']" />
<echo message="##teamcity[setParameter name='system.build.number' value='${build.num}']" />
I can see that this sets the values in TeamCity (after the build is complete):
But it must set these values after it has give the build a label in this list, because this is the label it has:
When I run the ant script in Eclipse, I see the outputs that I want, but does it not set them in time?
I also tried <echo message="##teamcity[buildnumber '${build.num}']" />
like this post suggests, but with no change in the result.
And I haven’t (yet) found anything useful in the documentation. This page seems like it says to do what I’ve tried…