The following plugin provides functionality available through Pipeline-compatible steps. Read more about how to integrate steps into your Pipeline in the Steps section of the Pipeline Syntax page.

For a list of other such plugins, see the Pipeline Steps Reference page.

Pipeline Maven Integration Plugin

withMaven: Provide Maven environment

Configures maven environment to use within a pipeline job by calling sh mvn or bat mvn. The selected maven installation will be configured and prepended to the path.
  • globalMavenSettingsConfig (optional)
    Select a global maven settings element from File Config Provider. The settings element in the settings.xml file contains elements used to define values which configure Maven execution in various ways, like the pom.xml, but should not be bundled to any specific project, or distributed to an audience. These include values such as the local repository location, alternate remote repository servers, and authentication information.

    see also: settings.xml reference

    • Type: String
  • globalMavenSettingsFilePath (optional)
    Specify a global maven settings.xml file. The specified path can be absolute or relative to the workspace. Shell-like environment variable expansions work in this field, by using the ${VARIABLE} syntax. The file existence is checked on the build agent, if found, that one is used. If not found it will be checked on the master. The settings element in the settings.xml file contains elements used to define values which configure Maven execution in various ways, like the pom.xml, but should not be bundled to any specific project, or distributed to an audience. These include values such as the local repository location, alternate remote repository servers, and authentication information.
    There are two locations where a settings.xml file per default may live:
    • The Maven install - default: $M2_HOME/conf/settings.xml
    • A user's install - default: ${user.home}/.m2/settings.xml
    The former settings.xml are also called global settings, the latter settings.xml are referred to as user settings. If both files exists, their contents gets merged, with the user-specific settings.xml being dominant.

    see also: settings.xml reference

    • Type: String
  • jdk (optional)
    Select a JDK installation. If auto-install is disabled, the JDK will be downloaded and made available for the pipeline job.

    Note: This option does not work with docker.image('xxx').inside or container('xxx'), the preinstalled JDK on the docker image will be used.

    • Type: String
  • maven (optional)
    Select a Maven installation. If auto-install is disabled, maven will be downloaded and made available for the pipeline job.

    Note: This option does not work with docker.image('xxx').inside or container('xxx'), the preinstalled maven on the docker image will be used.

    • Type: String
  • mavenLocalRepo (optional)
    Specify a custom local repository path. Shell-like environment variable expansions work with this field, by using the ${VARIABLE} syntax. Normally, Jenkins uses the local Maven repository as determined by Maven, by default ~/.m2/repository and can be overridden by <localRepository> in ~/.m2/settings.xml (see Configuring your Local Repository))

    This normally means that all the jobs that are executed on the same node shares a single Maven repository. The upside of this is that you can save the disk space, the downside is that the repository is not multi process safe and having multiple builds run concurrently can corrupt it. Additionally builds could interfere with each other by sharing incorrect or partially built artifacts. For example, you might end up having builds incorrectly succeed, just because your have all the dependencies in your local repository, despite that fact that none of the repositories in POM might have them.

    By using this option, Jenkins will tell Maven to use a custom path for the build as the local Maven repository by using -Dmaven.repo.local
    If specified as a relative path then this value well be resolved against the workspace root and not the current working directory.
    ie. if .repository is specified then $WORKSPACE/.repository will be used.

    This means each job could get its own isolated Maven repository just for itself. It fixes the above problems, at the expense of additional disk space consumption.

    When using this option, consider setting up a Maven artifact manager so that you don't have to hit remote Maven repositories too often.

    • Type: String
  • mavenOpts (optional)
    Specify JVM specific options needed when launching Maven as an external process, these are not maven specific options. See: Java Options

    Shell-like environment variable expansions work in this field, by using the ${VARIABLE} syntax.

    • Type: String
  • mavenSettingsConfig (optional)
    Select a maven settings element from File Config Provider. The settings element in the settings.xml file contains elements used to define values which configure Maven execution in various ways, like the pom.xml, but should not be bundled to any specific project, or distributed to an audience. These include values such as the local repository location, alternate remote repository servers, and authentication information.

    see also: settings.xml reference

    • Type: String
  • mavenSettingsFilePath (optional)
    Specify a maven settings.xml file. The specified path can be absolute or relative to the workspace. Shell-like environment variable expansions work in this field, by using the ${VARIABLE} syntax. The file existence is checked on the build agent, if found, that one is used. If not found it will be checked on the master. The settings element in the settings.xml file contains elements used to define values which configure Maven execution in various ways, like the pom.xml, but should not be bundled to any specific project, or distributed to an audience. These include values such as the local repository location, alternate remote repository servers, and authentication information.
    There are two locations where a settings.xml file per default may live:
    • The Maven install - default: $M2_HOME/conf/settings.xml
    • A user's install - default: ${user.home}/.m2/settings.xml
    The former settings.xml are also called global settings, the latter settings.xml are referred to as user settings. If both files exists, their contents gets merged, with the user-specific settings.xml being dominant.

    see also: settings.xml reference

    • Type: String
  • options (optional)
      Array / List of Nested Choice of Objects
    • concordionPublisher
      Publish Concordion reports, if found, regarding the given pattern.
      Test results are by default published if the Jenkins HTMLPublisher Plugin is installed.
      • disabled (optional)
        Skip the publishing of tests reports.
        • Type: boolean
    • dependenciesFingerprintPublisher
      Fingerprint the Maven dependencies used by the maven project.
      • disabled (optional)
        Skip the fingerprinting of the dependencies of the maven project.
        • Type: boolean
      • includeReleaseVersions (optional)
        • Type: boolean
      • includeScopeCompile (optional)
        • Type: boolean
      • includeScopeProvided (optional)
        • Type: boolean
      • includeScopeRuntime (optional)
        • Type: boolean
      • includeScopeTest (optional)
        • Type: boolean
      • includeSnapshotVersions (optional)
        • Type: boolean
    • findbugsPublisher
      Publish FindBugs reports generated by "org.codehaus.mojo:findbugs-maven-plugin:findbugs".
      FindBugs results are by default published if the Jenkins FindBugs Plugin is installed.
      • disabled (optional)
        Skip the publishing of findbugs reports.
        • Type: boolean
      • healthy (optional)
        • Type: String
      • thresholdLimit (optional)
        • Type: String
      • unHealthy (optional)
        • Type: String
    • artifactsPublisher
      Archive and fingerprint the artifact and the attached artifacts generated by the maven project.
      • disabled (optional)
        Skip the archiving and the fingerprinting of generated artifacts.
        • Type: boolean
    • invokerPublisher
      Publish Invoker reports generated by "org.apache.maven.plugins:maven-invoker-plugin:run".
      Invoker results are by default published if the Jenkins Maven Invoker Plugin is installed.
      • disabled (optional)
        Skip the publishing of invoker reports.
        • Type: boolean
    • jgivenPublisher
      Publish JGiven reports, if found.
      Test results are by default published if the Jenkins JGiven Plugin is installed.
      • disabled (optional)
        Skip the publishing of tests reports.
        • Type: boolean
    • jacocoPublisher
      Publish JaCoCo Java Code Coverage Library reports, if found.
      Test results are by default published if the Jenkins JaCoCo Plugin is installed.
      • disabled (optional)
        Skip the publishing of JaCoCo reports.
        • Type: boolean
    • junitPublisher
      Publish tests reports generated by "maven-surefire-plugin:test" or by "maven-failsafe-plugin:integration-test".
      Test results are by default published if the Jenkins JUnit Plugin is installed.
      • disabled (optional)
        Skip the publishing of tests reports.
        • Type: boolean
      • healthScaleFactor (optional)
        The amplification factor to apply to test failures when computing the test result contribution to the build health score.
        The default factor is 1.0
        • A factor of 0.0 will disable the test result contribution to build health score.
        • A factor of 0.1 means that 10% of tests failing will score 99% health
        • A factor of 0.5 means that 10% of tests failing will score 95% health
        • A factor of 1.0 means that 10% of tests failing will score 90% health
        • A factor of 2.0 means that 10% of tests failing will score 80% health
        • A factor of 2.5 means that 10% of tests failing will score 75% health
        • A factor of 5.0 means that 10% of tests failing will score 50% health
        • A factor of 10.0 means that 10% of tests failing will score 0% health
        The factor is persisted with the build results, so changes will only be reflected in new builds.
        • Type: double
      • ignoreAttachments (optional)
        Skip the publishing of tests reports attachments.
        Test result attachments are by default published if the Jenkins JUnit Attachments Plugin is installed.
        • Type: boolean
      • keepLongStdio (optional)
        If checked, any standard output or error from a test suite will be retained in the test results after the build completes. (This refers only to additional messages printed to console, not to a failure stack trace.) Such output is always kept if the test failed, but by default lengthy output from passing tests is truncated to save space. Check this option if you need to see every log message from even passing tests, but beware that Jenkins's memory consumption can substantially increase as a result, even if you never look at the test results!
        • Type: boolean
    • mavenLinkerPublisher
      This publisher generates and publishes the links (url) of deployed Maven artifacts.
      • disabled (optional)
        Skip generating and publishing the links.
        • Type: boolean
    • pipelineGraphPublisher
      Build a graph of pipelines based on their Maven dependencies and on the Maven artifacts they generate.
      • disabled (optional)
        Skip the fingerprinting of the dependencies of the maven project.
        • Type: boolean
      • ignoreUpstreamTriggers (optional)
        • Type: boolean
      • includeReleaseVersions (optional)
        • Type: boolean
      • includeScopeCompile (optional)
        • Type: boolean
      • includeScopeProvided (optional)
        • Type: boolean
      • includeScopeRuntime (optional)
        • Type: boolean
      • includeScopeTest (optional)
        • Type: boolean
      • includeSnapshotVersions (optional)
        • Type: boolean
      • lifecycleThreshold (optional)

        Threshold to trigger downstream pipelines based on the Maven lifecycle phase successfully reached during the Maven execution.

        If "install" is selected then downstream pipelines will be triggered for "mvn clean install", "mvn clean deploy" but NOT "mvn clean verify" or "mvn clean package".

        Example

        Configure a Jenkins Multibranch Pipeline with

        • Threshold: "deploy"
        • execution of "mvn clean deploy" on branches (incl. master) and execution of "mvn clean verify on pull requests
        So that:
        • The builds of branches (incl. "master") would upload the generated jar/war file to your enterprise Maven repository and would trigger downstream pipelines
        • The builds of pull request would only build the package but NOT upload the generated jar/war file to your enterprise Maven repository and would NOT trigger downstream pipelines

        • Type: String
      • skipDownstreamTriggers (optional)
        • Type: boolean
    • spotbugsPublisher
      Publish SpotBugs reports generated by "com.github.spotbugs:spotbugs-maven-plugin:spotbugs".
      SpotBugs results are by default published if the Jenkins FindBugs Plugin is installed.
      • disabled (optional)
        Skip the publishing of SpotBugs reports.
        • Type: boolean
      • healthy (optional)
        • Type: String
      • thresholdLimit (optional)
        • Type: String
      • unHealthy (optional)
        • Type: String
    • openTasksPublisher
      Publish Open Task Scanner reports.
      Open Task Scanner reports are by default published if the Jenkins Task Scanner Plugin is installed.
      The default setup is to look in Java source code for "FIXME" comments as high priority tasks and for "TODO" comments as normal priority tasks.
      • asRegexp (optional)
        Use task identifiers as regular expressions.
        • Type: boolean
      • disabled (optional)
        Skip the publishing of Task Scanner reports.
        • Type: boolean
      • excludePattern (optional)
        Ant style pattern of exclude source code.
        • Type: String
      • healthy (optional)
        • Type: String
      • highPriorityTaskIdentifiers (optional)
        Coma separated list of high priority task identifiers.
        • Type: String
      • ignoreCase (optional)
        Ignore case when scanning task identifiers.
        • Type: boolean
      • lowPriorityTaskIdentifiers (optional)
        Coma separated list of low priority task identifiers.
        • Type: String
      • normalPriorityTaskIdentifiers (optional)
        Coma separated list of normal priority task identifiers.
        • Type: String
      • pattern (optional)
        Ant style pattern of the source code to scan for task identifiers.
        • Type: String
      • thresholdLimit (optional)
        • Type: String
      • unHealthy (optional)
        • Type: String
  • publisherStrategy (optional)
    IMPLICIT All Maven publishers are implicitly enabled and used, even if they are not configured in "withMaven(options:...)".
    EXPLICIT Only the Maven publishers explicitly configured in "withMaven(options:...)" are used.
    • Values: IMPLICIT, EXPLICIT
  • tempBinDir (optional)
    Specify a custom temporary binaries directory. Allow to have a constant path to the maven binaries, then a constant environment for reproducible compilations. Some tools detect an environment change as a sources change, which will retrigger the compilation of all sources.
    • Type: String
  • traceability (optional)
    Should additional information be added to the script execution.

    Note: This option adds --show-version to the maven execution and marks the beginning of the maven wrapper script with ----- withMaven Wrapper script -----.

    • Type: boolean

Was this page helpful?

Please submit your feedback about this page through this quick form.

Alternatively, if you don't wish to complete the quick form, you can simply indicate if you found this page helpful?

    


See existing feedback here.