Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-47823

withMaven fails to inject Maven settings files with docker-pipeline 1.14

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • pipeline-maven-plugin
    • None
    • pipeline-maven-plugin 2.x+
      docker-pipeline plugin 1.14

    Description

      Problem Description

      The docker-pipeline changed its behavior with version 1.14 and is no longer allowing plugins to contribute the "PATH" environment variable.

      The Pipeline Maven Plugin contributes to the PATH environment variable to specify the "mvn" command line arguments such as the settings file.

      Due to this change of behavior, the Pipeline Maven Plugin is no longer able to inject specify Maven settings file.

      Workaround

      If you need to specify the Maven settings file in a dockerized build agent using the Docker Pipeline Plugin,

      References

      https://github.com/jenkinsci/docker-workflow-plugin/commit/f55c122fe10f28bf31ccfca66f0587facf508148#diff-4d69c729a160747eba5c12ea83f7753cR248

      https://github.com/jenkinsci/pipeline-maven-plugin/blob/pipeline-maven-3.0.2/jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepExecution.java#L279

      Attachments

        Issue Links

          Activity

            ncosta Nuno Costa added a comment -

            cleclerc, using the example you mentioned above works ok but I noticed some other issues. Not sure if this issues are only happening because this is just a beta:

            1. When invoking mvn command, uname is not found
              ----- withMaven Wrapper script -----
              /opt/apache-maven-3.1.1/bin/mvn: 1: /opt/apache-maven-3.1.1/bin/mvn: uname: not found
              ...
            1. We use maven plugins that triggers cmake, libboost, etc, and this commands/libraries are only found if I add its paths to the export command.
              ...
              sh "export PATH=$MVN_CMD_DIR:$PATH:opt/bin && mvn clean test"
              ...

              All those commands are already set in PATH but for some reason are not picked by the export command.
              Below more information about paths set inside a ubuntu 12.04 container. Build server on CentOS7.

              ...
              sh "echo $PATH"
              sh "which mvn"
              sh "which cmake"
              sh "echo $MVN_CMD_DIR"
              sh "env | grep PATH"
              sh "uname -r"
              sh "export PATH=$MVN_CMD_DIR:$PATH && which mvn && mvn -v"
              sh "echo $PATH"
              sh "which mvn"
              sh "which cmake"
              sh "env | grep PATH"
              ...
              

              Console output:

              Running shell script
              + echo /var/lib/jenkins/workspace/project/repo/branch/debug@tmp/withMaven476b8ef4:/usr/local/bin:/usr/bin
              /var/lib/jenkins/workspace/project/repo/branch/debug@tmp/withMaven476b8ef4:/usr/local/bin:/usr/bin
              sh
              Running shell script
              + which mvn
              /opt/apache-maven-3.1.1/bin/mvn
              sh
              Running shell script
              + which cmake
              /opt/bin/cmake
              sh
              Running shell script
              + echo /var/lib/jenkins/workspace/project/repo/branch/debug@tmp/withMaven476b8ef4
              /var/lib/jenkins/workspace/project/repo/branch/debug@tmp/withMaven476b8ef4
              sh
              Running shell script
              + env
              + grep PATH
              LIBRARY_PATH=/opt/qt/lib:/opt/lib:
              LD_LIBRARY_PATH=/opt/lib:
              PATH=/opt/bin:/opt/sonar-runner-2.4/bin:/opt/apache-maven-3.1.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
              CLASSPATH=
              sh
              Running shell script
              + uname -r
              4.4.83-1.el7.elrepo.x86_64
              sh
              Running shell script
              + export PATH=/var/lib/jenkins/workspace/project/repo/branch/debug@tmp/withMaven476b8ef4:/var/lib/jenkins/workspace/project/repo/branch/debug@tmp/withMaven476b8ef4:/usr/local/bin:/usr/bin
              + which mvn
              /var/lib/jenkins/workspace/project/repo/branch/debug@tmp/withMaven476b8ef4/mvn
              + mvn -v
              ----- withMaven Wrapper script -----
              /opt/apache-maven-3.1.1/bin/mvn: 1: /opt/apache-maven-3.1.1/bin/mvn: uname: not found
              Warning: JAVA_HOME environment variable is not set.
              Picked up JAVA_TOOL_OPTIONS: -Dmaven.ext.class.path="/var/lib/jenkins/workspace/project/repo/branch/debug@tmp/withMaven476b8ef4/pipeline-maven-spy.jar" -Dorg.jenkinsci.plugins.pipeline.maven.reportsFolder="/var/lib/jenkins/workspace/project/repo/branch/debug@tmp/withMaven476b8ef4"
              Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 16:22:22+0100)
              Maven home: /opt/apache-maven-3.1.1
              Java version: 1.8.0_111, vendor: Oracle Corporation
              Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
              Default locale: en_US, platform encoding: ANSI_X3.4-1968
              OS name: "linux", version: "4.4.83-1.el7.elrepo.x86_64", arch: "amd64", family: "unix"
              sh
              Running shell script
              + echo /var/lib/jenkins/workspace/project/repo/branch/debug@tmp/withMaven476b8ef4:/usr/local/bin:/usr/bin
              /var/lib/jenkins/workspace/project/repo/branch/debug@tmp/withMaven476b8ef4:/usr/local/bin:/usr/bin
              sh
              Running shell script
              + which mvn
              /opt/apache-maven-3.1.1/bin/mvn
              sh
              Running shell script
              + which cmake
              /opt/bin/cmake
              sh
              Running shell script
              + env
              + grep PATH
              LIBRARY_PATH=/opt/qt/lib:/opt/lib:
              LD_LIBRARY_PATH=/opt/lib:
              PATH=/opt/bin:/opt/sonar-runner-2.4/bin:/opt/apache-maven-3.1.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
              CLASSPATH=
              
            ncosta Nuno Costa added a comment - cleclerc , using the example you mentioned above works ok but I noticed some other issues. Not sure if this issues are only happening because this is just a beta: When invoking mvn command, uname is not found ----- withMaven Wrapper script ----- /opt/apache-maven-3.1.1/bin/mvn: 1: /opt/apache-maven-3.1.1/bin/mvn: uname: not found ... We use maven plugins that triggers cmake, libboost, etc, and this commands/libraries are only found if I add its paths to the export command. ... sh "export PATH=$MVN_CMD_DIR:$PATH:opt/bin && mvn clean test" ... All those commands are already set in PATH but for some reason are not picked by the export command. Below more information about paths set inside a ubuntu 12.04 container. Build server on CentOS7. ... sh "echo $PATH" sh "which mvn" sh "which cmake" sh "echo $MVN_CMD_DIR" sh "env | grep PATH" sh "uname -r" sh "export PATH=$MVN_CMD_DIR:$PATH && which mvn && mvn -v" sh "echo $PATH" sh "which mvn" sh "which cmake" sh "env | grep PATH" ... Console output: Running shell script + echo / var /lib/jenkins/workspace/project/repo/branch/debug@tmp/withMaven476b8ef4:/usr/local/bin:/usr/bin / var /lib/jenkins/workspace/project/repo/branch/debug@tmp/withMaven476b8ef4:/usr/local/bin:/usr/bin sh Running shell script + which mvn /opt/apache-maven-3.1.1/bin/mvn sh Running shell script + which cmake /opt/bin/cmake sh Running shell script + echo / var /lib/jenkins/workspace/project/repo/branch/debug@tmp/withMaven476b8ef4 / var /lib/jenkins/workspace/project/repo/branch/debug@tmp/withMaven476b8ef4 sh Running shell script + env + grep PATH LIBRARY_PATH=/opt/qt/lib:/opt/lib: LD_LIBRARY_PATH=/opt/lib: PATH=/opt/bin:/opt/sonar-runner-2.4/bin:/opt/apache-maven-3.1.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin CLASSPATH= sh Running shell script + uname -r 4.4.83-1.el7.elrepo.x86_64 sh Running shell script + export PATH=/ var /lib/jenkins/workspace/project/repo/branch/debug@tmp/withMaven476b8ef4:/ var /lib/jenkins/workspace/project/repo/branch/debug@tmp/withMaven476b8ef4:/usr/local/bin:/usr/bin + which mvn / var /lib/jenkins/workspace/project/repo/branch/debug@tmp/withMaven476b8ef4/mvn + mvn -v ----- withMaven Wrapper script ----- /opt/apache-maven-3.1.1/bin/mvn: 1: /opt/apache-maven-3.1.1/bin/mvn: uname: not found Warning: JAVA_HOME environment variable is not set. Picked up JAVA_TOOL_OPTIONS: -Dmaven.ext. class. path= "/ var /lib/jenkins/workspace/project/repo/branch/debug@tmp/withMaven476b8ef4/pipeline-maven-spy.jar" -Dorg.jenkinsci.plugins.pipeline.maven.reportsFolder= "/ var /lib/jenkins/workspace/project/repo/branch/debug@tmp/withMaven476b8ef4" Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 16:22:22+0100) Maven home: /opt/apache-maven-3.1.1 Java version: 1.8.0_111, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre Default locale: en_US, platform encoding: ANSI_X3.4-1968 OS name: "linux" , version: "4.4.83-1.el7.elrepo.x86_64" , arch: "amd64" , family: "unix" sh Running shell script + echo / var /lib/jenkins/workspace/project/repo/branch/debug@tmp/withMaven476b8ef4:/usr/local/bin:/usr/bin / var /lib/jenkins/workspace/project/repo/branch/debug@tmp/withMaven476b8ef4:/usr/local/bin:/usr/bin sh Running shell script + which mvn /opt/apache-maven-3.1.1/bin/mvn sh Running shell script + which cmake /opt/bin/cmake sh Running shell script + env + grep PATH LIBRARY_PATH=/opt/qt/lib:/opt/lib: LD_LIBRARY_PATH=/opt/lib: PATH=/opt/bin:/opt/sonar-runner-2.4/bin:/opt/apache-maven-3.1.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin CLASSPATH=

            Code changed in jenkins
            User: Cyrille Le Clerc
            Path:
            jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepExecution.java
            http://jenkins-ci.org/commit/pipeline-maven-plugin/52141ec07401eb73b94963e414f4075a2903e1b1
            Log:
            JENKINS-47823 better help in build logs

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Cyrille Le Clerc Path: jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/WithMavenStepExecution.java http://jenkins-ci.org/commit/pipeline-maven-plugin/52141ec07401eb73b94963e414f4075a2903e1b1 Log: JENKINS-47823 better help in build logs
            cleclerc Cyrille Le Clerc added a comment - - edited

            ncosta can you please open a different bug if the problem is not fixed. It may be a problem with the way docker-pipeline handles the $PATH or a problem with the way the $PATH is defined in your Docker image (please keep in mind that docker-pipeline no longer honors the entrypoint).

            Closing this defect as pipeline-maven-plugin 3.0.3 offers a solution to work with docker-pipeline 1.14: https://wiki.jenkins.io/display/JENKINS/Pipeline+Maven+Plugin#PipelineMavenPlugin-withMavenAndDockerPipeline

            cleclerc Cyrille Le Clerc added a comment - - edited ncosta can you please open a different bug if the problem is not fixed. It may be a problem with the way docker-pipeline handles the $PATH or a problem with the way the $PATH is defined in your Docker image (please keep in mind that docker-pipeline no longer honors the entrypoint). Closing this defect as pipeline-maven-plugin 3.0.3 offers a solution to work with docker-pipeline 1.14: https://wiki.jenkins.io/display/JENKINS/Pipeline+Maven+Plugin#PipelineMavenPlugin-withMavenAndDockerPipeline
            ncosta Nuno Costa added a comment -

            cleclerc, just created JENKINS-48284 with some details.

            ncosta Nuno Costa added a comment - cleclerc , just created JENKINS-48284 with some details.
            acejam Joshua Noble added a comment - joshtrow I know it's been a year, but I came up with a workaround for not having to update every mvn call here:  https://issues.jenkins-ci.org/browse/JENKINS-40484?focusedCommentId=352635&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-352635

            People

              cleclerc Cyrille Le Clerc
              cleclerc Cyrille Le Clerc
              Votes:
              2 Vote for this issue
              Watchers:
              13 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: