TeamCity Cloud 2021.1 Help

Gradle

The Gradle build runner runs Gradle projects.

To run builds with Gradle, Gradle 0.9-rc-1 or later must be installed on all the agent machines. Alternatively, if you use the Gradle wrapper, you need to have properly configured Gradle Wrapper scripts checked in to your Version Control.

The runner supports all Gradle build configurations, including build.gradle and build.gradle.kts.

Gradle Parameters

Option

Description

Gradle tasks

Specify Gradle task names separated by spaces. For example, :myproject:clean :myproject:build or clean build. If this field is left blank, the 'default' task is used. Note that TeamCity currently supports building Java projects with Gradle. Building Groovy, Scala, and other projects has not been tested.

Gradle build file

A path to the Gradle build file, relative to the working directory. If empty (default), Gradle uses own settings to determine it.

Incremental building

TeamCity can make use of the Gradle :buildDependents feature. If the Incremental building option is enabled, TeamCity will detect Gradle modules affected by changes in the build and start the :buildDependents command for them only. This will cause Gradle to fully build and test only the modules affected by changes.

Gradle home path

Specify here the path to the Gradle home directory (the parent of the bin directory). If not specified, TeamCity will use Gradle specified in the agent's GRADLE_HOME environment variable. If you don't have Gradle installed on agents, you can use a Gradle wrapper instead.

Additional Gradle command line parameters

Optionally, specify the space-separated list of command line parameters to be passed to Gradle.

Gradle Wrapper

If enabled, TeamCity will look for Gradle Wrapper scripts in the checkout directory, and launch the appropriate script with Gradle tasks and additional command line parameters specified in the fields above. In this case, Gradle specified in Gradle home path and Gradle installed on the agent are ignored.

Run Parameters

Option

Description

Debug

Selecting the Log debug messages checkbox is equivalent to adding the -d Gradle command-line parameter.

Stacktrace

Selecting the Print stacktrace checkbox is equivalent to adding the -s Gradle command-line parameter.

Java Parameters

Option

Description

JDK

Select a JDK. This section details the available options. The default is JAVA_HOME environment variable or the agent's own Java.

JDK home path

The option is available when <Custom> is selected above. Use this field to specify the path to your custom JDK used to run the build. If the field is left blank, the path to JDK Home is read either from the JAVA_HOME environment variable on the agent machine, or from the env.JAVA_HOME property specified in the build agent configuration file (buildAgent.properties). If these values are not specified, TeamCity uses the Java home of the build agent process itself.

JVM command line parameters

You can specify such JVM command line parameters, for example, maximum heap size or parameters enabling remote debugging. These values are passed by the JVM used to run your build.

Example:

-Xmx512m -Xms256m

Build properties

The TeamCity system parameters can be accessed in Gradle build scripts in the same way as Gradle properties. The recommended way to reference properties is as follows:

task printProperty { doLast { println "${teamcity['teamcity.build.id']}" } }
tasks.register("printProperty") { doLast { val teamcity: Map<*,*> by project println("${teamcity["teamcity.build.id"]}") } }

or if the system property's name is a legal name identifier (for example, system.myPropertyName = myPropertyValue):

task printProperty { doLast { println "$myPropertyName" } }
tasks.register("printProperty") { doLast { val myPropertyName: String by project println("$myPropertyName") } }

Docker Settings

In this section, you can specify a Docker image which will be used to run the build step.

Code Coverage

The Gradle build runner supports code coverage with based on the IDEA code coverage engine and JaCoCo.

Last modified: 06 May 2021