Access Build Counter as an environment variable

Hi, I have overridden the Build Number (BUILD_NUMBER) format to be

2.0.{0}.%system.build.vcs.number%

however I still require access to the build counter {0} from my scripts.

How can I access this number as an environment variable?

I've tried addong an environment variable with %system.build.number% and {0} as the value but neither of these gives the build counter number.

Can you make build counter a first-class environment variable instead of {0} or explain how to access it?



Attachment(s):
MWSnap046.png
3 comments
Comment actions Permalink

Hi

I can suggest an alternate approach: do not change build number format in configuration's settings, so both %BUILD_NUMBER% and %BUILD_VCS_NUMBER% variables have their original values. But replace it from the script using a service message.

0
Comment actions Permalink

Hi Michael,

Thanks for your reply, that helped. For those who come upon this thread this is what I did:

Background: In TeamCity I overrode BUILD_NUMBER from {0} to 2.0.{0}.%system.build.vcs.number% however this meant I couldnt use the 'raw' build number ({0}) in any of my scripts downstream.

To resolve this I:

1) Set Build Number Format in TeamCity back to {0}

2) Add 2.0.%build.number%.%system.build.vcs.number% as a environment varaible, env.ASS_PRODUCT, short for assembly product.

3) Emit this during the Visual Studio compile to update TeamCity to the 'real' build number. To do this I added this to the PreBuild event:
echo ##teamcity[buildNumber '%ASS_PRODUCT%']

You are now able to use the 'real' build number ('%ASS_PRODUCT%) or 'raw' build number (%BUILD_NUMBER%) in your scripts.

0
Comment actions Permalink

Thank you Wallace!


0

Please sign in to leave a comment.