Getting TeamCity internal properties (Build_Id, Build_Results_Link, etc.)


Is there a way to get some (or all) of Team City's environment variables? I have access to the predefined environment variables, like Build.Number, TeamCity.Project.Name, etc.

But I would like to get access to the Build_Id, the Build_Results_Link, a boolean value that tells me if the build passed or fail, etc. How can I do this? I'm using Team City 3.0 EAP

The reason is not too difficult: I want to pass those kind of information to a custom MSBuild task during the execution of a build by Team City.



Comment actions Permalink


Documented properties are listed in the TeamCity web administration UI in the build configuration's "Properties and environment variables" section.

Some additional properties that are intended for internal use by TeamCity are also passed as system and environment variables to the build process. If you feel you need them (taking the risk of adapting your code to future releases of TeamCity in case of changes), you can dump the environment of your build process and try to find necessary information there.

BTW you do not need internal buildId to construct the link to the build results: you can replace buildId URL parameter with buildNumber one and use the link like below:
to get the link to build number 435.

You can also pass values to the build script specifying custom system or environment properties in the "Properties and environment variables" build configuration settings section. e.g. you can pass build configuration URL to the build as a property with hardcoded value and then add buildNumber parameter to it when needed.

Hope, this helps.

Best regards,

Yegor Yarko
Quality Assurance Engineer
JetBrains, Inc
"Develop with pleasure!"

Comment actions Permalink

Hi Yegor,

Thanks for the reply!

How can I get the buildTypeId? It's not set in the 'Properties and Environment Variables'. Your link works perfectly, and all I need would be to get the Build Type Id.



Comment actions Permalink

Ok, this question just got answered.

teamcity_buildtype_id allows me to get the build_type_id information. I do keep in mind that this is an internal property and is therfore subject to change.

Thank you very much Yegor and Pavel,



Please sign in to leave a comment.