TeamCity 7.0 Help

Defining and Using Build Parameters in Build Configuration

To learn about build parameters in TeamCity, please refer to the Configuring Build Parameters page. In this section:

Defining Build Parameters in Build Configuration

On the Build Parameters page of Build Configuration settings you can define required system properties and environment variables to be passed to the build script and environment when a build is started. Note, that you can redefine them when launching a Custom Build.

Build Parameters defined in Build Configuration are used only within this configuration. For other ways, refer to Project and Agent Level Build Parameters.

Any user-defined build parameter (system property or environment variable)can reference other parameters by using the following format:

%[env|system].property_name% For example: system.tomcat.libs=%env.CATALINA_HOME%/lib/*.jar

Using Build Parameters in Build Configuration Settings

In most Build Configuration settings you can use a reference to a Build Parameter instead of using actual value. Before starting a build, TeamCity resolves all references with available parameters. If there are references that cannot be resolved, they are left as is and a warning will appear in the build log.

To make a reference to a build parameter just use it's name enclosed in percentage signs, e.g.: %\teamcity.build.number%

Any text appearing between percentage signs is considered a reference to a property by TeamCity. If the property cannot be found in the build configuration, the reference becomes an implicit agent requirement and such build configuration can only be run on an agent with the property defined. Agent-defined value will be used in the build.

If you want to prevent TeamCity from treating text in the percentage signs as reference to a property you can escape them by using two percentage signs. Every occurrence of "%%" in the values where property references are supported will be replaced to "%" before passing the value to the build. e.g. if you want to pass "%Y%m%d%H%M%S" into the build, change it to "%%Y%%m%%d%%H%%M%%S"

Where References Can Be Used

Group of settings

References notes

Build Runner settings, artifact specification

any of the properties that are passed into the build

User-defined properties and Environment variables

any of the properties that are passed into the build

Build Number format

only Predefined Build Parameters

VCS root and checkout rules settings

any of the properties that are passed into the build

VCS label pattern

system.build.number and Predefined Build Parameters

Artifact dependency settings

only Predefined Build Parameters

If you reference a build parameter in a build configuration, and it is not defined there, it becomes an Agent Requirements for the configuration. The build configuration will be run only on agents that have this property defined.

Using Build Parameters in VCS Labeling Pattern and Build Number

In Build number pattern and VCS labeling pattern you can use %[env|system].property_name% syntax to reference the properties that are known on the server-side. These are Predefined Build Parameters and Predefined Build Parameters predefined properties and properties defined in the settings of the build configuration on Build Parameters page. For example, VCS revision number: %\build.vcs.number%.

Using System Properties in Build Scripts

Any system property (system.<property name>) can be referenced in a build script by the property name:

  • For Ant, Maven and NAnt use ${<property name>}

  • For Gradle use teamcity["<property name>"]

  • For MSBuild (Visual Studio 2005/2008 Project Files) use $(<property name>)

To get the file names that store the full set of properties, use can use teamcity.build.properties.file system property of TEAMCITY_BUILD_PROPERTIES_FILE environment variable. see Predefined Build Parameters for details.

Last modified: 20 April 2023