Dela via


Gradle@1 - Gradle v1 task

Build using a Gradle wrapper script.

Inputs

gradleWrapperFile - Gradle Wrapper
Input alias: wrapperScript. string. Required. Default value: gradlew.

Specifies the gradlew wrapper's location within the repository that will be used for the build. Agents on Windows (including Microsoft-hosted agents) must use the gradlew.bat wrapper. Agents on Linux or macOS can use the gradlew shell script. Learn more about the Gradle Wrapper.


options - Options
string.

Specifies the command line options that will be passed to the Gradle wrapper. See Gradle Command Line for more information.


tasks - Tasks
string. Required. Default value: build.

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 for more information.


workingDirectory - Working Directory
Input alias: cwd. string.

Specifies the working directory to run the Gradle build. The task uses the repository root directory if the working directory is not specified.


publishJUnitResults - Publish to TFS/Team Services
boolean. Default value: true.

Publishes JUnit test results produced by the Gradle build to Azure Pipelines. The task publishes each test results file matching Test Results Files as a test run in Azure Pipelines.


testResultsFiles - Test Results Files
string. Required when publishJUnitResults = true. Default value: **/build/test-results/TEST-*.xml.

The file path for test results. Wildcards can be used. For example, **/TEST-*.xml for all XML files whose name starts with TEST-.


testRunTitle - Test Run Title
string. Optional. Use when publishJUnitResults = true.

Provides a name for the JUnit test case results for this build.


codeCoverageToolOption - Code Coverage Tool
Input alias: codeCoverageTool. string. Allowed values: None, Cobertura, JaCoCo. Default value: None.

Specifies a code coverage tool to determine the code that is covered by the test cases for the build.


codeCoverageClassFilesDirectories - Class Files Directories
Input alias: classFilesDirectories. string. Required when codeCoverageTool = false. Default value: build/classes/main/.

The comma-separated list of directories containing class files and archive files (.jar, .war, and more). Code coverage is reported for class files in these directories. Normally, the task searches classes under build/classes/java/main (for Gradle 4+), which is the default class directory for Gradle builds.


codeCoverageClassFilter - Class Inclusion/Exclusion Filters
Input alias: classFilter. string. Optional. Use when codeCoverageTool != None.

The comma-separated list of filters to include or exclude classes from collecting code coverage. For example: +:com.*,+:org.*,-:my.app*.*.


codeCoverageFailIfEmpty - Fail When Code Coverage Results Are Missing
Input alias: failIfCoverageEmpty. boolean. Optional. Use when codeCoverageTool != None. Default value: false.

Fails the build if code coverage did not produce any results to publish.


javaHomeOption - Set JAVA_HOME by
Input alias: javaHomeSelection. string. Required. Allowed values: JDKVersion (JDK Version), Path. Default value: JDKVersion.

Sets JAVA_HOME by selecting a JDK version that the task discovers during builds or by manually entering a JDK path.


jdkVersionOption - JDK Version
Input alias: jdkVersion. string. Optional. Use when javaHomeSelection = JDKVersion. Allowed values: default, 1.9 (JDK 9), 1.8 (JDK 8), 1.7 (JDK 7), 1.6 (JDK 6). Default value: default.

Attempts to discover the path to the selected JDK version and set JAVA_HOME accordingly.


jdkDirectory - JDK Path
Input alias: jdkUserInputPath. string. Required when javaHomeSelection = Path.

Sets JAVA_HOME to the given path.


jdkArchitectureOption - JDK Architecture
Input alias: jdkArchitecture. string. Optional. Use when jdkVersion != default. Allowed values: x86, x64. Default value: x64.

Supplies the JDK architecture (x86 or x64).


gradleOptions - Set GRADLE_OPTS
Input alias: gradleOpts. string. Default value: -Xmx1024m.

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.


sonarQubeRunAnalysis - Run SonarQube Analysis
Input alias: sqAnalysisEnabled. boolean. Default value: false.

Runs a SonarQube analysis after executing the current goals. install or package goals should be executed first.


sonarQubeServiceEndpoint - SonarQube Endpoint
Input alias: sqConnectedServiceName. string. Required when sqAnalysisEnabled = true.

The endpoint that specifies the SonarQube server to use.


sonarQubeProjectName - SonarQube Project Name
Input alias: sqProjectName. string. Required when sqAnalysisEnabled = true.

The SonarQube project name, that is sonar.projectName.


sonarQubeProjectKey - SonarQube Project Key
Input alias: sqProjectKey. string. Required when sqAnalysisEnabled = true.

The SonarQube project unique key, that is sonar.projectKey.


sonarQubeProjectVersion - SonarQube Project Version
Input alias: sqProjectVersion. string. Required when sqAnalysisEnabled = true.

The SonarQube project version, that is sonar.projectVersion.


sonarQubeGradlePluginVersion - SonarQube Gradle Plugin Version
Input alias: sqGradlePluginVersion. string. Required when sqAnalysisEnabled = true. Default value: 2.0.1.

Contains the version number of the SpotBugs Gradle plugin.


sonarQubeSpecifyDB - The SonarQube server version is lower than 5.2
Input alias: sqDbDetailsRequired. boolean. Optional. Use when sqAnalysisEnabled = true. Default value: false.

SonarQube server 5.1 and lower only. Specifies the database connection details.


sonarQubeDBUrl - Db Connection String
Input alias: sqDbUrl. string. Optional. Use when sqDbDetailsRequired = true.

SonarQube server version 5.1 and lower only. Enters the database connection setting, that is sonar.jdbc.url. For example: jdbc:jtds:sqlserver://localhost/sonar;SelectMethod=Cursor.


sonarQubeDBUsername - Db Username
Input alias: sqDbUsername. string. Optional. Use when sqDbDetailsRequired = true.

SonarQube server 5.1 and lower only. Enters the username for the database user, that is sonar.jdbc.username.


sonarQubeDBPassword - Db User Password
Input alias: sqDbPassword. string. Optional. Use when sqDbDetailsRequired = true.

SonarQube server 5.1 and lower only. Enter the password for the database user, that is sonar.jdbc.password.


sonarQubeIncludeFullReport - Include full analysis report in the build summary (SQ 5.3+)
Input alias: sqAnalysisIncludeFullReport. boolean. Optional. Use when sqAnalysisEnabled = true. Default value: true.

Delays the build until the SonarQube analysis is completed.


sonarQubeFailWhenQualityGateFails - Fail the build on quality gate failure (SQ 5.3+)
Input alias: sqAnalysisBreakBuildIfQualityGateFailed. boolean. Optional. Use when sqAnalysisEnabled = true.

SonarQube server version 5.3 or above only. Introduces delays as the build must wait for SonarQube to complete the analysis. Learn more about using SonarQube for builds.


checkStyleRunAnalysis - Run Checkstyle
Input alias: checkstyleAnalysisEnabled. boolean. Default value: false.

Runs the Checkstyle tool with the default Sun checks. Results are uploaded as build artifacts.


findBugsRunAnalysis - Run FindBugs
Input alias: findbugsAnalysisEnabled. boolean. Default value: false.

Uses 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 the SpotBugs plugin instead.


pmdRunAnalysis - Run PMD
Input alias: pmdAnalysisEnabled. boolean. Default value: false.

Uses the PMD Java static analysis tool to look for bugs in the code. The results are uploaded as build artifacts.


Task control options

All tasks have control options in addition to their task inputs. For more information, see Control options and common task properties.

Output variables

None.

Remarks

Note

There is a newer version of this task available at Gradle@2.

Configuration of the SonarQube analysis was moved to the SonarQube or SonarCloud extensions in the task Prepare Analysis Configuration.

Use this task to build using a Gradle wrapper script.

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 -Dhttp.socketTimeout=60000 -Dhttp.connectionTimeout=60000 to Options. This increases the timeout from 10 seconds to 1 minute.

Requirements

Requirement Description
Pipeline types YAML, Classic build
Runs on Agent, DeploymentGroup
Demands Self-hosted agents must have capabilities that match the following demands to run jobs that use this task: java
Capabilities This task does not satisfy any demands for subsequent tasks in the job.
Command restrictions Any
Settable variables Any
Agent version 1.91.0 or greater
Task category Build