次の方法で共有


Gradle task

TFS 2017 | TFS 2015

Use this task to build using a Gradle wrapper script.

Arguments

Argument Description
wrapperScript
Gradle Wrapper

(Required) 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 gradlew.bat wrapper. Agents on Linux or macOS can use the gradlew shell script.

See The Gradle Wrapper.


Default value: gradlew
Argument aliases: gradleWrapperFile
options
Options

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

See Gradle Command Line.

tasks
Tasks

(Required) The task(s) for Gradle to execute. A list of task names should be separated by spaces and can be taken from gradlew tasks issued from a command prompt.

See Gradle Build Script Basics.


Default value: build

JUnit test results options

Argument Description
publishJUnitResults
Publish to Azure Pipelines
(Required) Select this option to publish JUnit Test results produced by the Gradle build to Azure Pipelines/TFS.
Default value: true
testResultsFiles
Test results files
(Required) Test results files path. Wildcards can be used. For example, */TEST-.xml for all xml files whose name starts with TEST-."
Default value: **/TEST-*.xml
testRunTitle
Test run title
(Optional) Assign a title for the JUnit test case results for this build.

Code coverage options

Argument Description
codeCoverageTool
Code coverage tool
(Optional) Choose a code coverage tool to determine the code that is covered by the test cases for the build.
Default value: None
Argument aliases: codeCoverageToolOption
classFilesDirectories
Class files directories
(Required) Comma-separated list of directories containing class files and archive files (JAR, WAR, etc.). Code coverage is reported for class files in these directories. Normally, classes under `build/classes/main` are searched, which is the default class directory for Gradle builds
Default value: build/classes/main/
Argument aliases: codeCoverageClassFilesDirectories
classFilter
Class inclusion/exclusion filters
(Optional) Comma-separated list of filters to include or exclude classes from collecting code coverage. For example: +:com.*,+:org.*,-:my.app*.*."
Argument aliases: codeCoverageClassFilter
failIfCoverageEmpty
Fail when code coverage results are missing
(Optional) Fail the build if code coverage did not produce any results to publish
Default value: false
Argument aliases: codeCoverageFailIfEmpty

Advanced options

Argument Description
cwd
Working directory
(Optional) Working directory in which to run the Gradle build. If not specified, the repository root directory is used
javaHomeSelection
Set JAVA_HOME by
(Required) Sets JAVA_HOME either by selecting a JDK version that will be discovered during builds or by manually entering a JDK path
Default value: JDKVersion
Argument aliases: javaHomeOption
jdkVersion
JDK version
(Optional) Will attempt to discover the path to the selected JDK version and set JAVA_HOME accordingly
Argument aliases: jdkDirectory
jdkUserInputPath
JDK path
(Required) Sets JAVA_HOME to the given path
Default value: default
Argument aliases: jdkVersionOption
jdkArchitecture
JDK Architecture
(Optional) Optionally supply the architecture (x86, x64) of JDK.
Default value: x64
Argument aliases: jdkArchitectureOption
gradleOpts
Set GRADLE_OPTS
(Optional) Sets the GRADLE_OPTS environment variable, which is used to send command-line arguments to start the JVM. The xmx flag specifies the maximum memory available to the JVM.
Default value: -Xmx1024m
Argument aliases: gradleOptions

Code analysis options

Argument Description
sqAnalysisEnabled
Run SonarQube or SonarCloud Analysis
(Required) This option has changed from version 1 of the Gradle task to use the SonarQube and SonarCloud marketplace extensions. Enable this option to run SonarQube or SonarCloud analysis after executing tasks in the Tasks field. You must also add a Prepare Analysis Configuration task from one of the extensions to the build pipeline before this Gradle task
Default value: false
Argument aliases: sonarQubeRunAnalysis
sqGradlePluginVersionChoice
SonarQube scanner for Gradle version
(Required) The SonarQube Gradle plugin version to use. You can declare it in your Gradle configuration file, or specify a version here
Default value: specify
sqGradlePluginVersion
SonarQube scanner for Gradle plugin version
(Required) Refer for all available versions
Default value: 2.6.1
Argument aliases: sonarQubeGradlePluginVersion
checkstyleAnalysisEnabled
Run Checkstyle
(Optional) Run the Checkstyle tool with the default Sun checks. Results are uploaded as build artifacts.
Default value: false
Argument aliases: checkStyleRunAnalysis
findbugsAnalysisEnabled
Run FindBugs
(Optional) Use the FindBugs static analysis tool to look for bugs in the code. Results are uploaded as build artifacts. In Gradle 6.0 this plugin was removed. Use spotbugs plugin instead. More info.
Default value: false
Argument aliases: findBugsRunAnalysis
pmdAnalysisEnabled
Run PMD
(Optional) Use the PMD Java static analysis tool to look for bugs in the code. Results are uploaded as build artifacts
Default value: false
Argument aliases: pmdRunAnalysis
spotBugsAnalysisEnabled
Run Spotbugs
(Required) Enable this option to run spotBugs. This plugin works with Gradle v5.6 or later. Results are uploaded as build artifacts. More info. Please make sure that you are using Gradle 5.6 or later. If you are using an earlier version of Gradle, the plugin may work in an unexpected way or may not work at all.
Default value: false
Argument aliases: spotBugsAnalysis
spotBugsGradlePluginVersionChoice
Spotbugs plugin for Gradle version
(Required) The Spotbugs Gradle plugin version to use. You can declare it in your Gradle configuration file, or specify a version here.
Default value: specify
spotbugsGradlePluginVersion
Spotbugs for Gradle plugin version
(Required) Refer for all available versions.
Default value: 4.7.0
Argument aliases: spotbugsGradlePluginVersion

Task control options

Example

Build your Java app with Gradle

Open source

This task is open source on GitHub. Feedback and contributions are welcome.

FAQ

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.

  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 gradle-wrapper.properties.

    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 Options -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.

I'm having problems. How can I troubleshoot them?

See Troubleshoot Build and Release.

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.

My NuGet push task is failing with the following error: "Error: unable to get local issuer certificate". How can I fix this?

This can be fixed by adding a trusted root certificate. You can either add the NODE_EXTRA_CA_CERTS=file environment variable to your build agent, or you can add the NODE.EXTRA.CA.CERTS=file task variable in your pipeline. See Node.js documentation for more details about this variable. See Set variables in a pipeline for instructions on setting a variable in your pipeline.

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

Some of these features are available only on Azure Pipelines and not yet available on-premises. Some features are available on-premises if you have upgraded to the latest version of TFS.