Share via


Maven@2 - Maven v2 task

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

Inputs

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

Specifies the relative path from the repository root to the Maven POM file.


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


options - Options
string.


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

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


testResultsFiles - Test results files
string. Required when publishJUnitResults = true. Default value: **/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.


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

Specifies the code coverage tool.


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.


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.


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

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


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

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


mavenSetM2Home - Set M2_HOME variable
boolean. Optional. Use 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. Default value: true.

Automatically authenticates with Azure Artifacts feeds. If Artifacts feeds are not in use, deselect this option for faster builds.


sonarQubeRunAnalysis - Run SonarQube or SonarCloud analysis
Input alias: sqAnalysisEnabled. boolean. 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.


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


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.

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