TeamCity Cloud 2024.03 Help

Requirement Conditions

This page explains conditions used in agent requirements or build step execution requirements.

Condition

Description and Example

exists

Returns true if the specified property exists.

For example:

exists("DotNetCLI_Path")

does not exist

Returns true if the specified property does not exist.

For example:

doesNotExist("env.TEAMCITY_GIT_PATH")

equals

Returns true if the specified property exists and equals the given value.

You can leave the Value field empty to check whether the specified property exists but is empty.

For example:

equals("docker.server.osType", "Linux")

does not equal

Returns true if a value of the specified property differs from the given value, or if this property does not exist.

You can leave the Value field empty to check whether the specified property exists and is not empty (has a value).

For example:

doesNotEqual("system.teamcity.buildType.id", "Tests")

is not more than

Return true if a value of the target numeric property meets the corresponding condition.

For example:

moreThan("build.number", "256")

lessThan("teamcity.agent.hardware.cpuCount", "10")

is more than

is less than

is not less than

version is more than

Compare software versions with the given value. Supports multiple value formats, including dot (.) delimiters, leading zeroes, common suffixes like beta or EAP. If the version number contains alphabetic characters, they are compared as well, for instance, 1.1e < 1.1g.

For example:

moreThanVer("maven", "3.0")

version is not more than

version is less than

version is not less than

contains

Returns true if a value of the specified property includes the given value.

For example:

contains("teamcity.serverUrl", "localhost")

does not contain

Returns true if a value of the specified property does not include the given value, or if this property does not exist.

For example:

doesNotContain("system.agent.name", "_local")

starts with

Returns true if a value of the specified property starts (ends) with the given value.

For example:

startsWith("teamcity.agent.jvm.os.name", "Mac")

endsWith("teamcity.agent.work.dir", "/work")

ends with

matches

Returns true if the specified property matches (does not match) the given regular expression pattern.

For example, use matches("CUSTOM_PARAMETER", ".*(,|^)foo(,|$).*") to match all occurrences of foo, foo,bar, bar,foo, and bar,foo,xxx.

does not match

Combining Conditions

When multiple requirements are defined, they are implicitly joined by boolean AND. For example, the following set of conditions requires that both the env.JDK_17_0 parameter AND the env.JDK_21_0 parameter exist:

requirements { exists("env.JDK_17_0") exists("env.JDK_21_0") }

There is no mechanism available for joining requirements with boolean OR.

Last modified: 05 February 2024