Using Properties

Skip to end of metadata
Go to start of metadata
You are viewing documentation of TeamCity 4.x, which is not the most recent released version of TeamCity. Please refer to the listing to choose another version.
Search

Searching TeamCity 4.x Documentation

Table of Contents

The properties of a Build Configuration can be used:

Also, predefined Agent Properties are used in the 7.Agent Requirements.

The properties fall into two categories:

  • environment variables - defined in the corresponding section of the Build Configuration settings. Within TeamCity the properties that correspond to the environment variables have names starting with "env." prefix.
  • system properties - defined in the corresponding section of the Build Configuration settings. Names start with "system." prefix.

Using Properties in the build

The properties are passed to the build as environment variables and as system properties of the build script.

Any runner gets the environment variables that are a combined set of:

  • environment variables of the Build Agent process itself
  • env.* properties defined in the agent's buildAgent.properties file
  • env.* properties defined in the Build Configuration
  • env.* properties redefined in the Run Custom Build dialog
  • pre-defined environment variables
  • env.* properties that came from teamcity.default.properties file

env. prefix is trimmed from the properties before passing them into environment.

Scripts run with Ant, NAnt, MSBuild runners get properties from a combined set of:

  • system.* properties defined in the agent's buildAgent.properties file
  • system.* properties defined in the Build Configuration
  • system.* properties redefined in the Run Custom Build dialog
  • pre-defined system properties
  • system.* properties that came from teamcity.default.properties file

system. prefix is trimmed from the properties before passing them into the build script.

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

  • For Ant and NAnt use ${<property name>}
  • For MSBuild (Visual Studio 2005/2008 Project Files) use $(<property name>)
  • Don't forget to leave the "system." part out of the system properties.
  • When using MSBuild, replace "." with "_" when you reference property names.

Using Properties in Build Configuration Settings

Many settings of a build configuration allow to use a reference to the Build Configuration properties. Before being passed into a build, all the references will be resolved with the available properties. If there will be references that cannot be resolved, they will be left as is and a warning will be logged into the build log.

The properties should be referenced as system.<property_name> for system properties and env.<variable_name> for environment variable.

Values of the following settings support references:

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 Server Build Predefined Properties
VCS label pattern system.build.number and Server Build Predefined Properties
Artifact dependency settings only Server Build Predefined Properties

The references are made by enclosing the full property name including env./system. prefixes into percentage signs.
Any user-defined property can reference other properties by using the following format:

Any property that is referenced in a build configuration, but is not defined, becomes an agent requirement for the configuration. The build configuration will be run only on agents that have this property defined.

Using Properties 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 server and reference predefined properties and properties defined in the settings of the build configuration on Properties and environment variables page.



See Also:

Labels:

referencing referencing Delete
property property Delete
build build Delete
configuration configuration Delete
Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.