Useful environment variables in TeamCity

Here is the list of useful environment variables in TeamCity.

  1. TEAMCITY_BUILDCONF_NAME- stores the name of build configuration
  2. TEAMCITY_GIT_PATH – path of git
  3. TEAMCITY_JRE – JRE path being used
  4. TEAMCITY_PROJECT_NAME – name of TeamCity project
  5. COMPUTERNAME- Name of the computer running the build
  6. BUILD_NUMBER – build number

You can access these variables in Java using below code. In other languages, you can use the language specific code to read environment variables.

Map<String, String> env = System.getenv();
        for (String envName : env.keySet()) {
            System.out.println(envName + " --- > " + env.get(envName));

You may also like...