Skip to content

pipeline-maven-3.0.3

Compare
Choose a tag to compare
@cyrille-leclerc cyrille-leclerc released this 29 Jan 15:16
· 1118 commits to master since this release
  • JENKINS-47823 withMaven fails to inject Maven settings files with docker-pipeline 1.14. When using withMaven in docker.image('my-image').inside{} and docker-pipeline 1.14:
    • Either prepend the PATH environment varizbles when invoking "mvn"
sh 'export PATH=$MVN_CMD_DIR:$PATH && mvn clean deploy'
sh './mvnw clean deploy'
  • Introduce the MVN_CMD_DIR environment variable in addition to the MVN_CMD variable introduced in 3.0.3-beta-1 because a file cannot be added to the PATH, it must be the parent folder of this file that is added to the PATH

Pattern to use withMaven() in a docker.image().inside{} step of docker-pipeline 1.14

node("linux-agent-with-docker") {
    docker.image('maven').inside {
        withMaven(mavenSettingsConfig: 'my-maven-settings') {

            git "https://github.com/cyrille-leclerc/my-jar.git"

            // prepend the $MVN_CMD_DIR variable to the $PATH environment variable 
            // in each "sh" step that invokes mvn 
            sh 'export PATH=$MVN_CMD_DIR:$PATH && mvn help:effective-settings'
        }
    }
}

Troubleshooting

// prepend the $MVN_CMD_DIR variable to the $PATH environment variable 
// in each "sh" step that invokes mvn
// for troubleshooting, we display `which mvn` 
sh 'export PATH=$MVN_CMD_DIR:$PATH && which mvn && mvn help:effective-settings'