How to fetch the branch and the build number directly from TeamCity?

I have a very large project that has lots of branches and multiple builds that are built continuously. What I want is to run my automation tests written in Go such that they first fetch the build number as well as the branch from TeamCity and then based on some validations run the tests accordingly.

I had tried giving a build number directly from inside my code, but that is a flawed approach as it isn't able to figure out the branch it needs to look at to find the build.

0
1 comment

Hello,

How exactly do you start these tests? The values you are after are available as predefined build parameters build.number and teamcity.build.branch. Depending on how the tests are started, you could either pass them as startup parameters or read them from the environment variables. For the latter, you could define an environment variable that points to the branch parameter, for example:

env.BUILD_BRANCH = %teamcity.build.branch%

The env.BUILD_NUMBER is available out of the box. 

0

Please sign in to leave a comment.