Maven@3 - Maven v3 task

Use this task to build, test, and deploy with Apache Maven.

Syntax

# Maven v3
# Build, test, and deploy with Apache Maven.
- task: Maven@3
  inputs:
    mavenPOMFile: 'pom.xml' # string. Required. Maven POM file. Default: pom.xml.
    #goals: 'package' # string. Goal(s). Default: package.
    #options: # string. Options. 
  # JUnit Test Results
    publishJUnitResults: true # boolean. Required. Publish to Azure Pipelines. Default: true.
    testResultsFiles: '**/surefire-reports/TEST-*.xml' # string. Required when publishJUnitResults = true. Test results files. Default: **/surefire-reports/TEST-*.xml.
    #testRunTitle: # string. Optional. Use when publishJUnitResults = true. Test run title. 
    #allowBrokenSymlinks: true # boolean. Alias: allowBrokenSymbolicLinks. Optional. Use when publishJUnitResults = true. Allow broken symbolic links. Default: true.
  # Code Coverage
    #codeCoverageToolOption: 'None' # 'None' | 'Cobertura' | 'JaCoCo'. Alias: codeCoverageTool. Code coverage tool. Default: None.
    #codeCoverageClassFilter: # string. Alias: classFilter. Optional. Use when codeCoverageTool != None. Class inclusion/exclusion filters. 
    #codeCoverageClassFilesDirectories: # string. Alias: classFilesDirectories. Optional. Use when codeCoverageTool = JaCoCo. Class files directories. 
    #codeCoverageSourceDirectories: # string. Alias: srcDirectories. Optional. Use when codeCoverageTool = JaCoCo. Source files directories. 
    #codeCoverageFailIfEmpty: false # boolean. Alias: failIfCoverageEmpty. Optional. Use when codeCoverageTool != None. Fail when code coverage results are missing. Default: false.
    #codeCoverageRestoreOriginalPomXml: false # boolean. Alias: restoreOriginalPomXml. Optional. Use when codeCoverageTool != None. Restore original pom.xml after task execution. Default: false.
  # Advanced
    javaHomeOption: 'JDKVersion' # 'JDKVersion' | 'Path'. Alias: javaHomeSelection. Required. Set JAVA_HOME by. Default: JDKVersion.
    #jdkVersionOption: 'default' # 'default' | '1.17' | '1.11' | '1.10' | '1.9' | '1.8' | '1.7' | '1.6'. Alias: jdkVersion. Optional. Use when javaHomeSelection = JDKVersion. JDK version. Default: default.
    #jdkDirectory: # string. Alias: jdkUserInputPath. Required when javaHomeSelection = Path. JDK path. 
    #jdkArchitectureOption: 'x64' # 'x86' | 'x64'. Alias: jdkArchitecture. Optional. Use when jdkVersion != default. JDK architecture. Default: x64.
    mavenVersionOption: 'Default' # 'Default' | 'Path'. Alias: mavenVersionSelection. Required. Maven version. Default: Default.
    #mavenDirectory: # string. Alias: mavenPath. Required when mavenVersionSelection = Path. Maven path. 
    #mavenSetM2Home: false # boolean. Required when mavenVersionSelection = Path. Set M2_HOME variable. Default: false.
    #mavenOptions: '-Xmx1024m' # string. Alias: mavenOpts. Set MAVEN_OPTS to. Default: -Xmx1024m.
    mavenAuthenticateFeed: false # boolean. Alias: mavenFeedAuthenticate. Required. Authenticate built-in Maven feeds. Default: false.
    effectivePomSkip: false # boolean. Alias: skipEffectivePom. Required. Skip generating effective POM while authenticating built-in feeds. Default: false.
  # Code Analysis
    sonarQubeRunAnalysis: false # boolean. Alias: sqAnalysisEnabled. Required. Run SonarQube or SonarCloud analysis. Default: false.
    #isJacocoCoverageReportXML: false # boolean. Optional. Use when sqAnalysisEnabled = true && codeCoverageTool = JaCoCo. Use XML Jacoco reports for SonarQube analysis. Default: false.
    #sqMavenPluginVersionChoice: 'latest' # 'latest' | 'pom'. Required when sqAnalysisEnabled = true. SonarQube scanner for Maven version. Default: latest.
    #checkStyleRunAnalysis: false # boolean. Alias: checkstyleAnalysisEnabled. Run Checkstyle. Default: false.
    #pmdRunAnalysis: false # boolean. Alias: pmdAnalysisEnabled. Run PMD. Default: false.
    #findBugsRunAnalysis: false # boolean. Alias: findbugsAnalysisEnabled. Run FindBugs. Default: false.
    #spotBugsRunAnalysis: false # boolean. Alias: spotBugsAnalysisEnabled. Run SpotBugs analysis. Default: false.
    #spotBugsVersion: '4.5.3.0' # string. Alias: spotBugsMavenPluginVersion. Optional. Use when spotBugsAnalysisEnabled = true. Version number. Default: 4.5.3.0.
    #spotBugsGoal: 'spotbugs' # 'spotbugs' | 'check'. Optional. Use when spotBugsAnalysisEnabled = true. The goal for the spotbugs plugin. Default: spotbugs.
    #failWhenBugsFound: true # boolean. Alias: spotBugsFailWhenBugsFound | sbFailWhenBugsFound. Optional. Use when spotBugsAnalysisEnabled = true && spotBugsGoal = check. Fail when bugs are found with spotbugs:check. Default: true.
# Maven v3
# Build, test, and deploy with Apache Maven.
- task: Maven@3
  inputs:
    mavenPOMFile: 'pom.xml' # string. Required. Maven POM file. Default: pom.xml.
    #goals: 'package' # string. Goal(s). Default: package.
    #options: # string. Options. 
  # JUnit Test Results
    publishJUnitResults: true # boolean. Required. Publish to Azure Pipelines. Default: true.
    testResultsFiles: '**/surefire-reports/TEST-*.xml' # string. Required when publishJUnitResults = true. Test results files. Default: **/surefire-reports/TEST-*.xml.
    #testRunTitle: # string. Optional. Use when publishJUnitResults = true. Test run title. 
  # Code Coverage
    #codeCoverageToolOption: 'None' # 'None' | 'Cobertura' | 'JaCoCo'. Alias: codeCoverageTool. Code coverage tool. Default: None.
    #codeCoverageClassFilter: # string. Alias: classFilter. Optional. Use when codeCoverageTool != None. Class inclusion/exclusion filters. 
    #codeCoverageClassFilesDirectories: # string. Alias: classFilesDirectories. Optional. Use when codeCoverageTool = JaCoCo. Class files directories. 
    #codeCoverageSourceDirectories: # string. Alias: srcDirectories. Optional. Use when codeCoverageTool = JaCoCo. Source files directories. 
    #codeCoverageFailIfEmpty: false # boolean. Alias: failIfCoverageEmpty. Optional. Use when codeCoverageTool != None. Fail when code coverage results are missing. Default: false.
    #codeCoverageRestoreOriginalPomXml: false # boolean. Alias: restoreOriginalPomXml. Optional. Use when codeCoverageTool != None. Restore original pom.xml after task execution. Default: false.
  # Advanced
    javaHomeOption: 'JDKVersion' # 'JDKVersion' | 'Path'. Alias: javaHomeSelection. Required. Set JAVA_HOME by. Default: JDKVersion.
    #jdkVersionOption: 'default' # 'default' | '1.11' | '1.10' | '1.9' | '1.8' | '1.7' | '1.6'. Alias: jdkVersion. Optional. Use when javaHomeSelection = JDKVersion. JDK version. Default: default.
    #jdkDirectory: # string. Alias: jdkUserInputPath. Required when javaHomeSelection = Path. JDK path. 
    #jdkArchitectureOption: 'x64' # 'x86' | 'x64'. Alias: jdkArchitecture. Optional. Use when jdkVersion != default. JDK architecture. Default: x64.
    mavenVersionOption: 'Default' # 'Default' | 'Path'. Alias: mavenVersionSelection. Required. Maven version. Default: Default.
    #mavenDirectory: # string. Alias: mavenPath. Required when mavenVersionSelection = Path. Maven path. 
    #mavenSetM2Home: false # boolean. Required when mavenVersionSelection = Path. Set M2_HOME variable. Default: false.
    #mavenOptions: '-Xmx1024m' # string. Alias: mavenOpts. Set MAVEN_OPTS to. Default: -Xmx1024m.
    mavenAuthenticateFeed: false # boolean. Alias: mavenFeedAuthenticate. Required. Authenticate built-in Maven feeds. Default: false.
    effectivePomSkip: false # boolean. Alias: skipEffectivePom. Required. Skip generating effective POM while authenticating built-in feeds. Default: false.
  # Code Analysis
    sonarQubeRunAnalysis: false # boolean. Alias: sqAnalysisEnabled. Required. Run SonarQube or SonarCloud analysis. Default: false.
    #isJacocoCoverageReportXML: false # boolean. Optional. Use when sqAnalysisEnabled = true && codeCoverageTool = JaCoCo. Use XML Jacoco reports for SonarQube analysis. Default: false.
    #sqMavenPluginVersionChoice: 'latest' # 'latest' | 'pom'. Required when sqAnalysisEnabled = true. SonarQube scanner for Maven version. Default: latest.
    #checkStyleRunAnalysis: false # boolean. Alias: checkstyleAnalysisEnabled. Run Checkstyle. Default: false.
    #pmdRunAnalysis: false # boolean. Alias: pmdAnalysisEnabled. Run PMD. Default: false.
    #findBugsRunAnalysis: false # boolean. Alias: findbugsAnalysisEnabled. Run FindBugs. Default: false.
# Maven v3
# Build, test, and deploy with Apache Maven.
- task: Maven@3
  inputs:
    mavenPOMFile: 'pom.xml' # string. Required. Maven POM file. Default: pom.xml.
    #goals: 'package' # string. Goal(s). Default: package.
    #options: # string. Options. 
  # JUnit Test Results
    publishJUnitResults: true # boolean. Required. Publish to Azure Pipelines. Default: true.
    testResultsFiles: '**/surefire-reports/TEST-*.xml' # string. Required when publishJUnitResults = true. Test results files. Default: **/surefire-reports/TEST-*.xml.
    #testRunTitle: # string. Optional. Use when publishJUnitResults = true. Test run title. 
  # Code Coverage
    #codeCoverageToolOption: 'None' # 'None' | 'Cobertura' | 'JaCoCo'. Alias: codeCoverageTool. Code coverage tool. Default: None.
    #codeCoverageClassFilter: # string. Alias: classFilter. Optional. Use when codeCoverageTool != None. Class inclusion/exclusion filters. 
    #codeCoverageClassFilesDirectories: # string. Alias: classFilesDirectories. Optional. Use when codeCoverageTool = JaCoCo. Class files directories. 
    #codeCoverageSourceDirectories: # string. Alias: srcDirectories. Optional. Use when codeCoverageTool = JaCoCo. Source files directories. 
    #codeCoverageFailIfEmpty: false # boolean. Alias: failIfCoverageEmpty. Optional. Use when codeCoverageTool != None. Fail when code coverage results are missing. Default: false.
  # Advanced
    javaHomeOption: 'JDKVersion' # 'JDKVersion' | 'Path'. Alias: javaHomeSelection. Required. Set JAVA_HOME by. Default: JDKVersion.
    #jdkVersionOption: 'default' # 'default' | '1.11' | '1.10' | '1.9' | '1.8' | '1.7' | '1.6'. Alias: jdkVersion. Optional. Use when javaHomeSelection = JDKVersion. JDK version. Default: default.
    #jdkDirectory: # string. Alias: jdkUserInputPath. Required when javaHomeSelection = Path. JDK path. 
    #jdkArchitectureOption: 'x64' # 'x86' | 'x64'. Alias: jdkArchitecture. Optional. Use when jdkVersion != default. JDK architecture. Default: x64.
    mavenVersionOption: 'Default' # 'Default' | 'Path'. Alias: mavenVersionSelection. Required. Maven version. Default: Default.
    #mavenDirectory: # string. Alias: mavenPath. Required when mavenVersionSelection = Path. Maven path. 
    #mavenSetM2Home: false # boolean. Required when mavenVersionSelection = Path. Set M2_HOME variable. Default: false.
    #mavenOptions: '-Xmx1024m' # string. Alias: mavenOpts. Set MAVEN_OPTS to. Default: -Xmx1024m.
    mavenAuthenticateFeed: false # boolean. Alias: mavenFeedAuthenticate. Required. Authenticate built-in Maven feeds. Default: false.
    effectivePomSkip: false # boolean. Alias: skipEffectivePom. Required. Skip generating effective POM while authenticating built-in feeds. Default: false.
  # Code Analysis
    sonarQubeRunAnalysis: false # boolean. Alias: sqAnalysisEnabled. Required. Run SonarQube or SonarCloud analysis. Default: false.
    #sqMavenPluginVersionChoice: 'latest' # 'latest' | 'pom'. Required when sqAnalysisEnabled = true. SonarQube scanner for Maven version. Default: latest.
    #checkStyleRunAnalysis: false # boolean. Alias: checkstyleAnalysisEnabled. Run Checkstyle. Default: false.
    #pmdRunAnalysis: false # boolean. Alias: pmdAnalysisEnabled. Run PMD. Default: false.
    #findBugsRunAnalysis: false # boolean. Alias: findbugsAnalysisEnabled. Run FindBugs. Default: false.
# Maven v3
# Build, test, and deploy with Apache Maven.
- task: Maven@3
  inputs:
    mavenPOMFile: 'pom.xml' # string. Required. Maven POM file. Default: pom.xml.
    #goals: 'package' # string. Goal(s). Default: package.
    #options: # string. Options. 
  # JUnit Test Results
    publishJUnitResults: true # boolean. Required. Publish to Azure Pipelines. Default: true.
    testResultsFiles: '**/surefire-reports/TEST-*.xml' # string. Required when publishJUnitResults = true. Test results files. Default: **/surefire-reports/TEST-*.xml.
    #testRunTitle: # string. Optional. Use when publishJUnitResults = true. Test run title. 
  # Code Coverage
    #codeCoverageToolOption: 'None' # 'None' | 'Cobertura' | 'JaCoCo'. Alias: codeCoverageTool. Code coverage tool. Default: None.
    #codeCoverageClassFilter: # string. Alias: classFilter. Optional. Use when codeCoverageTool != None. Class inclusion/exclusion filters. 
    #codeCoverageClassFilesDirectories: # string. Alias: classFilesDirectories. Optional. Use when codeCoverageTool = JaCoCo. Class files directories. 
    #codeCoverageSourceDirectories: # string. Alias: srcDirectories. Optional. Use when codeCoverageTool = JaCoCo. Source files directories. 
    #codeCoverageFailIfEmpty: false # boolean. Alias: failIfCoverageEmpty. Optional. Use when codeCoverageTool != None. Fail when code coverage results are missing. Default: false.
  # Advanced
    javaHomeOption: 'JDKVersion' # 'JDKVersion' | 'Path'. Alias: javaHomeSelection. Required. Set JAVA_HOME by. Default: JDKVersion.
    #jdkVersionOption: 'default' # 'default' | '1.11' | '1.10' | '1.9' | '1.8' | '1.7' | '1.6'. Alias: jdkVersion. Optional. Use when javaHomeSelection = JDKVersion. JDK version. Default: default.
    #jdkDirectory: # string. Alias: jdkUserInputPath. Required when javaHomeSelection = Path. JDK path. 
    #jdkArchitectureOption: 'x64' # 'x86' | 'x64'. Alias: jdkArchitecture. Optional. Use when jdkVersion != default. JDK architecture. Default: x64.
    mavenVersionOption: 'Default' # 'Default' | 'Path'. Alias: mavenVersionSelection. Required. Maven version. Default: Default.
    #mavenDirectory: # string. Alias: mavenPath. Required when mavenVersionSelection = Path. Maven path. 
    #mavenSetM2Home: false # boolean. Required when mavenVersionSelection = Path. Set M2_HOME variable. Default: false.
    #mavenOptions: '-Xmx1024m' # string. Alias: mavenOpts. Set MAVEN_OPTS to. Default: -Xmx1024m.
    mavenAuthenticateFeed: false # boolean. Alias: mavenFeedAuthenticate. Required. Authenticate built-in Maven feeds. Default: false.
  # Code Analysis
    sonarQubeRunAnalysis: false # boolean. Alias: sqAnalysisEnabled. Required. Run SonarQube or SonarCloud analysis. Default: false.
    #sqMavenPluginVersionChoice: 'latest' # 'latest' | 'pom'. Required when sqAnalysisEnabled = true. SonarQube scanner for Maven version. Default: latest.
    #checkStyleRunAnalysis: false # boolean. Alias: checkstyleAnalysisEnabled. Run Checkstyle. Default: false.
    #pmdRunAnalysis: false # boolean. Alias: pmdAnalysisEnabled. Run PMD. Default: false.
    #findBugsRunAnalysis: false # boolean. Alias: findbugsAnalysisEnabled. Run FindBugs. Default: false.
# Maven v3
# Build with Apache Maven.
- task: Maven@3
  inputs:
    mavenPOMFile: 'pom.xml' # string. Required. Maven POM file. Default: pom.xml.
    #goals: 'package' # string. Goal(s). Default: package.
    #options: # string. Options. 
  # JUnit Test Results
    publishJUnitResults: true # boolean. Required. Publish to Azure Pipelines/TFS. Default: true.
    testResultsFiles: '**/surefire-reports/TEST-*.xml' # string. Required when publishJUnitResults = true. Test results files. Default: **/surefire-reports/TEST-*.xml.
    #testRunTitle: # string. Optional. Use when publishJUnitResults = true. Test run title. 
  # Code Coverage
    #codeCoverageToolOption: 'None' # 'None' | 'Cobertura' | 'JaCoCo'. Alias: codeCoverageTool. Code coverage tool. Default: None.
    #codeCoverageClassFilter: # string. Alias: classFilter. Optional. Use when codeCoverageTool != None. Class inclusion/exclusion filters. 
    #codeCoverageClassFilesDirectories: # string. Alias: classFilesDirectories. Optional. Use when codeCoverageTool = JaCoCo. Class files directories. 
    #codeCoverageSourceDirectories: # string. Alias: srcDirectories. Optional. Use when codeCoverageTool = JaCoCo. Source files directories. 
    #codeCoverageFailIfEmpty: false # boolean. Alias: failIfCoverageEmpty. Optional. Use when codeCoverageTool != None. Fail when code coverage results are missing. Default: false.
  # Advanced
    javaHomeOption: 'JDKVersion' # 'JDKVersion' | 'Path'. Alias: javaHomeSelection. Required. Set JAVA_HOME by. Default: JDKVersion.
    #jdkVersionOption: 'default' # 'default' | '1.11' | '1.10' | '1.9' | '1.8' | '1.7' | '1.6'. Alias: jdkVersion. Optional. Use when javaHomeSelection = JDKVersion. JDK version. Default: default.
    #jdkDirectory: # string. Alias: jdkUserInputPath. Required when javaHomeSelection = Path. JDK path. 
    #jdkArchitectureOption: 'x64' # 'x86' | 'x64'. Alias: jdkArchitecture. Optional. Use when jdkVersion != default. JDK architecture. Default: x64.
    mavenVersionOption: 'Default' # 'Default' | 'Path'. Alias: mavenVersionSelection. Required. Maven version. Default: Default.
    #mavenDirectory: # string. Alias: mavenPath. Required when mavenVersionSelection = Path. Maven path. 
    #mavenSetM2Home: false # boolean. Required when mavenVersionSelection = Path. Set M2_HOME variable. Default: false.
    #mavenOptions: '-Xmx1024m' # string. Alias: mavenOpts. Set MAVEN_OPTS to. Default: -Xmx1024m.
    mavenAuthenticateFeed: false # boolean. Alias: mavenFeedAuthenticate. Required. Authenticate built-in Maven feeds. Default: false.
  # Code Analysis
    sonarQubeRunAnalysis: false # boolean. Alias: sqAnalysisEnabled. Required. Run SonarQube or SonarCloud analysis. Default: false.
    #sqMavenPluginVersionChoice: 'latest' # 'latest' | 'pom'. Required when sqAnalysisEnabled = true. SonarQube scanner for Maven version. Default: latest.
    #checkStyleRunAnalysis: false # boolean. Alias: checkstyleAnalysisEnabled. Run Checkstyle. Default: false.
    #pmdRunAnalysis: false # boolean. Alias: pmdAnalysisEnabled. Run PMD. Default: false.
    #findBugsRunAnalysis: false # boolean. Alias: findbugsAnalysisEnabled. Run FindBugs. Default: false.

Inputs

mavenPOMFile - Maven POM file
string. Required. Default value: pom.xml.

Specifies the relative path from the repository root to the Maven POM file. See Introduction to the POM for more information.


goals - Goal(s)
string. Default value: package.

(Optional) Set to package to compile your code and package it into a .war file. If you leave this argument blank, the build will fail. See Introduction to the Maven build lifecycle for more information.


options - Options
string.

(Optional) Specifies any Maven command-line options you want to use.


publishJUnitResults - Publish to Azure Pipelines
boolean. Required. Default value: true.

Specifies the option to publish the JUnit test results produced by the Maven build to Azure Pipelines. Each test results file matching Test Results Files will be published as a test run in Azure Pipelines.


publishJUnitResults - Publish to Azure Pipelines/TFS
boolean. Required. Default value: true.

Specifies the option to publish the JUnit test results produced by the Maven build to Azure Pipelines/TFS. Each test results file matching Test Results Files will be published as a test run in Azure Pipelines/TFS.


testResultsFiles - Test results files
string. Required when publishJUnitResults = true. Default value: **/surefire-reports/TEST-*.xml.

Specifies the path and pattern of test results files to publish.
Wildcards can be used.
More information about file matching patterns.
For example, **/TEST-*.xml for all XML files whose name starts with TEST-. If no root path is specified, files are matched beneath the default working directory, the value of which is available in the variable $(System.DefaultWorkingDirectory). For example, a value of **/TEST-*.xml will actually result in matching files from $(System.DefaultWorkingDirectory)/**/TEST-*.xml.


testRunTitle - Test run title
string. Optional. Use when publishJUnitResults = true.

Specifies a name for the test run.


allowBrokenSymlinks - Allow broken symbolic links
Input alias: allowBrokenSymbolicLinks. boolean. Optional. Use when publishJUnitResults = true. Default value: true.

If set to false, fails the build when the task finds a broken symbolic link while publishing tests result.


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

Specifies the code coverage tool. Enabling code coverage inserts the clean goal into the Maven goals list when Maven runs.


codeCoverageClassFilter - Class inclusion/exclusion filters
Input alias: classFilter. string. Optional. Use when codeCoverageTool != None.

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


codeCoverageClassFilesDirectories - Class files directories
Input alias: classFilesDirectories. string. Optional. Use when codeCoverageTool = JaCoCo.

This field is required for a multi-module project.
Specifies a comma-separated list of relative paths from the Maven POM file to directories containing class files and archive files (JAR, WAR, etc.). Code coverage is reported for class files in these directories. For example, target/classes,target/testClasses.


codeCoverageSourceDirectories - Source files directories
Input alias: srcDirectories. string. Optional. Use when codeCoverageTool = JaCoCo.

This field is required for a multi-module project.
Specifies a comma-separated list of relative paths from the Maven POM file to source code directories. Code coverage reports use these to highlight source code. For example, src/java,src/Test.


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.


codeCoverageRestoreOriginalPomXml - Restore original pom.xml after task execution
Input alias: restoreOriginalPomXml. boolean. Optional. Use when codeCoverageTool != None. Default value: false.

Code coverage modifies pom.xml to produce results. Use this option if you need to keep the original pom.xml.


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

Sets JAVA_HOME either by selecting a JDK version that will be discovered during builds or by manually entering a JDK path. If you already have Java installed on the agent machine, you can specify it by setting up javaHomeOption as path and jdkDirectory as a path to the JDK installed directory.


jdkVersionOption - JDK version
Input alias: jdkVersion. string. Optional. Use when javaHomeSelection = JDKVersion. Allowed values: default, 1.17 (JDK 17), 1.11 (JDK 11), 1.10 (JDK 10 (out of support)), 1.9 (JDK 9 (out of support)), 1.8 (JDK 8), 1.7 (JDK 7), 1.6 (JDK 6 (out of support)). Default value: default.

Attempts to discover the path to the selected JDK version and sets JAVA_HOME accordingly.
Note: If running on an agent that is not hosted by Microsoft, and the requested Java version is not the one indicated by the JAVA_HOME variable set on the agent machine, the task will rely on the variable JAVA_HOME_{version}_{arch} (for example: JAVA_HOME_8_X64) to locate the necessary JDK. Ensure this variable is set on self-hosted agents for any version and architecture of the JDK that may be requested by this parameter and/or by jdkArchitecture.


jdkVersionOption - JDK version
Input alias: jdkVersion. string. Optional. Use when javaHomeSelection = JDKVersion. Allowed values: default, 1.11 (JDK 11), 1.10 (JDK 10 (out of support)), 1.9 (JDK 9 (out of support)), 1.8 (JDK 8), 1.7 (JDK 7), 1.6 (JDK 6 (out of support)). Default value: default.

Attempts to discover the path to the selected JDK version and sets 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 architecture (x86, x64) of the JDK.


mavenVersionOption - Maven version
Input alias: mavenVersionSelection. string. Required. Allowed values: Default, Path (Custom Path). Default value: Default.

Specifies either the default Maven version or the version in the specified custom path.


mavenDirectory - Maven path
Input alias: mavenPath. string. Required when mavenVersionSelection = Path.

Supplies the custom path to the Maven installation (for example: /usr/share/maven).


mavenSetM2Home - Set M2_HOME variable
boolean. Required when mavenVersionSelection = Path. Default value: false.

Sets the M2_HOME variable to a custom Maven installation path.


mavenOptions - Set MAVEN_OPTS to
Input alias: mavenOpts. string. Default value: -Xmx1024m.

Sets the MAVEN_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.


mavenAuthenticateFeed - Authenticate built-in Maven feeds
Input alias: mavenFeedAuthenticate. boolean. Required. Default value: false.

Automatically authenticates built-in Maven feeds from the Azure Artifacts/TFS Package Management extension. If built-in Maven feeds are not in use, deselect this option for faster builds.


effectivePomSkip - Skip generating effective POM while authenticating built-in feeds
Input alias: skipEffectivePom. boolean. Required. Default value: false.

Authenticates built-in Maven feeds using the POM only, which allows parent POMs in Azure Artifacts/Azure DevOps Server [Package Management] feeds.


sonarQubeRunAnalysis - Run SonarQube or SonarCloud analysis
Input alias: sqAnalysisEnabled. boolean. Required. Default value: false.

This option has changed from using version 1 of the Maven task to using the SonarQube and SonarCloud marketplace extensions.
Enable this option to run SonarQube or SonarCloud analysis after executing goals in the Goals field. The install or package goal should run first. Before this Maven task, you must also add a Prepare Analysis Configuration task from one of the extensions to the build pipeline.


isJacocoCoverageReportXML - Use XML Jacoco reports for SonarQube analysis
boolean. Optional. Use when sqAnalysisEnabled = true && codeCoverageTool = JaCoCo. Default value: false.

Uses XML Jacoco reports for SonarQube analysis. Learn more about test reports.


sqMavenPluginVersionChoice - SonarQube scanner for Maven version
string. Required when sqAnalysisEnabled = true. Allowed values: latest (Use latest release), pom (Use version declared in your pom.xml). Default value: latest.

Specifies the SonarQube Maven plugin version to use. You can use the latest version or rely on the version in your pom.xml.


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

Runs the Checkstyle tool with the default Sun checks. If no Checkstyle configuration is specified in the pom.xml file, default Sun checks are used. Results are uploaded as build artifacts.


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

Uses the PMD static analysis tool to look for bugs in the code. 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.


spotBugsRunAnalysis - Run SpotBugs analysis
Input alias: spotBugsAnalysisEnabled. boolean. Default value: false.

Enable this option to run the SpotBugs code analysis plugin. More information about the SpotBugs Maven plugin.


spotBugsVersion - Version number
Input alias: spotBugsMavenPluginVersion. string. Optional. Use when spotBugsAnalysisEnabled = true. Default value: 4.5.3.0.

Learn about the available versions of SpotBugs.


spotBugsGoal - The goal for the spotbugs plugin
string. Optional. Use when spotBugsAnalysisEnabled = true. Allowed values: spotbugs ("spotbugs" - Creates a report on found bugs), check ("check" - Pipeline fails if bugs were detected). Default value: spotbugs.

Specifies the goal of the plugin. Learn more about SpotBugs goals.


failWhenBugsFound - Fail when bugs are found with spotbugs:check
Input alias: spotBugsFailWhenBugsFound | sbFailWhenBugsFound. boolean. Optional. Use when spotBugsAnalysisEnabled = true && spotBugsGoal = check. Default value: true.

Fails when bugs are found if Check Goal is specified. Learn more about SpotBug parameter details.


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

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

Important

When using the -q option in your MAVEN_OPTS, an effective pom won't be generated correctly, and Azure Artifacts feeds may not be able to be authenticated.

Important

If the JDK version you want to use is already installed on your agent, set javaHomeOption to path and set the jdkDirectory to the path of the JDK version. These options set the JAVA_HOME_11_X64 environment variable, which is required by the Maven task. This environment variable is set automatically if you are using the Java Tool installer task.

FAQ

I have a multi-module project, but my build is failing. What should I check?

Make sure you have specified #codeCoverageClassFilesDirectories and #codeCoverageSourceDirectories as a task input. These two parameters are optional for a single module project but are required for multi-module projects.

Examples

Requirements

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

See also