Using Properties
The properties of a Build Configuration can be used:
Also, Predefined 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
fileenv.* properties defined in the Build Configuration
env.* properties redefined in the Run Custom Build dialog
Predefined Properties 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
filesystem.* properties defined in the Build Configuration
system.* properties redefined in the Run Custom Build dialog
Predefined Properties 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>)
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 | |
VCS label pattern |
|
Artifact dependency settings |
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:
%[env|system].property_name% For example: system.tomcat.libs=%env.CATALINA_HOME%/lib/*.jar
Any property that is referenced in a build configuration, but is not defined, becomes an Agent Requirements 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 Predefined Properties and Predefined Properties predefined properties and properties defined in the settings of the build configuration on 6.Properties and environment variables page.