Build: Gradle

Last Update: 9/26/2016

Team Services | TFS 2017 | TFS 2015 | Previous versions (XAML builds)

Build using a Gradle wrapper script


Argument Description
Gradle Wrapper

The location in the repository of the gradlew wrapper used for the build. Note that on Windows build agents (including the hosted pool), you must use the gradlew.bat wrapper. Xplat build agents use the gradlew shell script.

See The Gradle Wrapper.


Specify any command line options you want to pass to the Gradle wrapper.

See Gradle Command Line.


The task(s) for Gradle to execute. A list of tasks can be taken from gradlew tasks issued from a command prompt.

See Gradle Build Script Basics.

JUnit Test Results
Publish to Visual Studio Team Services/TFS Select this option to publish JUnit Test results produced by the Gradle build to Visual Studio Team Services/TFS.
Test Results Files Test results files path. Wildcards can be used. For example, **/TEST-*.xml for all xml files whose name starts with TEST-."
Test Run Title Assign a title for the JUnit test case results for this build.
Code Coverage
Code Coverage Tool Choose a code coverage tool to determine the code that is covered by the test cases for the build.
Working Directory Directory on the build agent where the Gradle wrapper will be invoked from. Defaults to the repository root.
Set JAVA_HOME by JDK Version Choose which JDK level to run Gradle with. Will attempt to find JDK version and assign JAVA_HOME before running Gradle.
Set JAVA_HOME by Path Directory on build agent where JDK is located.
JDK Architecture Optionally supply the architecture (x86, x64) of JDK.
Code Analysis
Run SonarQube Analysis Select if you want to run a SonarQube analysis. See The Gradle build task now supports SonarQube analysis.
Run PMD Analysis Select if you want to perform a PMD static analysis. A build result page for each project is shown on the Artifacts tab of the completed build. See Gradle build task now also supports PMD analysis.
Run Checkstyle Analysis Select if you want to perform a Checkstyle static analysis The build summary reports the number of issues found by Checkstyle. Detailed issue logs are available under the build Artifact tab of the build summary. If the Checkstyle analysis is customized, the task only attempts to find the reports and produce a summary.
Control options


How do I generate a wrapper from my Gradle project?

The Gradle wrapper allows the build agent to download and configure the exact Gradle environment that is checked into the repoistory without having any software configuration on the build agent itself other than the JVM.

  1. Create the Gradle wrapper by issuing the following command from the root project directory where your build.gradle resides:

    jamal@fabrikam> gradle wrapper

  2. Upload your Gradle wrapper to your remote repository.

    There is a binary artifact that is generated by the gradle wrapper ( located at gradle/wrapper/gradle-wrapper.jar ). This binary file is small and doesn't require updating. If you need to change the Gradle configuration run on the build agent, you update the

    The repository should look something like this:

|-- gradle/
    `-- wrapper/
        `-- gradle-wrapper.jar
|-- src/
|-- .gitignore
|-- build.gradle
|-- gradlew
|-- gradlew.bat

How do I build an Android project?

Android Build

Do I need a build agent?

You need at least one agent to run your build. Get an agent.

I can't select a default agent queue and I can't queue my build. How do I fix this?

See queues.

I use Team Foundation Server on-premises and I don't see some of these features. Why not?

Some of these features are available only on Visual Studio Team Services and not yet available on-premises. Some features are available on-premises if you have upgraded to the latest version of TFS.