Azure Pipelines | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015
Use this task in a build or release pipeline to build using a Gradle wrapper script.
# Gradle # Build using a Gradle wrapper script - task: Gradle@2 inputs: #gradleWrapperFile: 'gradlew' #workingDirectory: # Optional #options: # Optional #tasks: 'build' #publishJUnitResults: true #testResultsFiles: '**/TEST-*.xml' # Required when publishJUnitResults == True #testRunTitle: # Optional #codeCoverageToolOption: 'None' # Optional. Options: none, cobertura, jaCoCo #codeCoverageClassFilesDirectories: 'build/classes/main/' # Required when codeCoverageToolOption == False #codeCoverageClassFilter: # Optional #codeCoverageFailIfEmpty: false # Optional #javaHomeOption: 'JDKVersion' # Options: jDKVersion, path #jdkVersionOption: 'default' # Optional. Options: default, 1.11, 1.10, 1.9, 1.8, 1.7, 1.6 #jdkDirectory: # Required when javaHomeOption == Path #jdkArchitectureOption: 'x64' # Optional. Options: x86, x64 #gradleOptions: '-Xmx1024m' # Optional #sonarQubeRunAnalysis: false #sqGradlePluginVersionChoice: 'specify' # Required when sonarQubeRunAnalysis == True# Options: specify, build #sonarQubeGradlePluginVersion: '2.6.1' # Required when sonarQubeRunAnalysis == True && SqGradlePluginVersionChoice == Specify #checkStyleRunAnalysis: false # Optional #findBugsRunAnalysis: false # Optional #pmdRunAnalysis: false # Optional
The location in the repository of the gradlew wrapper used for the build. For agents on Windows (including Microsoft-hosted agents), you must use the
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
|JUnit Test Results|
|Publish to Azure Pipelines/TFS||Select this option to publish JUnit Test results produced by the Gradle build to Azure Pipelines/TFS.|
|Test Results Files||Test results files path. Wildcards can be used. For example,
|Test Run Title||Assign a title for the JUnit test case results for this build.|
|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.|
This task is open source on GitHub. Feedback and contributions are welcome.
Q & A
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 repository without having any software configuration on the build agent itself other than the JVM.
Create the Gradle wrapper by issuing the following command from the root project directory where your build.gradle resides:
jamal@fabrikam> gradle wrapper
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 `-- gradle-wrapper.properties |-- src/ |-- .gitignore |-- build.gradle |-- gradlew |-- gradlew.bat
How do I fix timeouts when downloading dependencies?
To fix errors such as
Read timed out when downloading dependencies, users of Gradle 4.3+ can change the timeout
by adding to
-Dhttp.socketTimeout=60000 -Dhttp.connectionTimeout=60000. This increases the timeout
from 10 seconds to 1 minute.
Do I need an agent?
You need at least one agent to run your build or release. Get an agent for Linux, macOS, or Windows.
I can't select a default agent pool and I can't queue my build or release. How do I fix this?
See Agent pools.
Send feedback about: