Provides maven integration with Pipeline Plugin by using the withMaven step, which configures a maven environment to use within a pipeline job by calling sh mvn or bat mvn.


Withn a node or a docker.image block, create a withMaven block to setup a with maven environment. The configured environment will be used when calling maven inside the block by using sh mvn or bat mvn. The following parameters can be used to configure maven:

The Pipeline Syntax snippet code generator can be used to assist on generating the withMaven step parameters

An example pipeline script using the plugin would be:

    // Mark the code checkout 'stage'....
    stage 'Checkout'

    // Get some code from a GitHub repository
    git url: 'https://github.com/alvarolobato/maven_test.git'

    // Mark the code build
    stage 'Build'

            maven: 'M3', 
            mavenSettingsConfig: 'maven-settings-for-gameoflife', 
            mavenLocalRepo: '.repository') {

        // Run the maven build
        sh "mvn clean install"

In the above example the following parameters are use to configure maven:

Known Limitations

Maven and JDK installers do not work with "docker.image('xxx').inside{...}" as the docker step does not allow the use of Tool Installer, the preinstalled Maven and JDK on the docker image will be auto-discovered and used.