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

withEnv not setting PATH environment variable

    Details

    • Similar Issues:

      Description

      With a pipeline definition similar to

      pipeline {
          agent {
              docker {
                  image 'registry/org/buildagent'
              }
          }
      
          tools {
              jdk 'jdk-1.7.0_131'
              maven 'maven-3.5.0'
          }
      
          stages {
              stage ('Build') {
                  steps {
                      sh('mvn deploy')
                  }
              }
          }
      }

      The following message is generated

      + mvn deploy
      /workspace/project@tmp/durable-d723cc26/script.sh: line 2: mvn: command not found

      This exact script works with Jenkins 2.73.1 and the Pipeline Model API 1.2.5 plugin

        Attachments

          Activity

          Hide
          bkeyser_dgi Brian Keyser added a comment -

          The following configuration also does not configure the PATH environment variable correctly

          withEnv(["PATH=${tool 'maven-3.5.0'}/bin:${tool 'jdk-1.7.0_131'}/bin:${env.PATH}"]) {
              sh('mvn deploy')
          }
          Show
          bkeyser_dgi Brian Keyser added a comment - The following configuration also does not configure the PATH environment variable correctly withEnv(["PATH=${tool 'maven-3.5.0'}/bin:${tool 'jdk-1.7.0_131'}/bin:${env.PATH}"]) { sh('mvn deploy') }
          Hide
          abayer Andrew Bayer added a comment -

          This looks to be something with withEnv's behavior. I'll look into it.

          Show
          abayer Andrew Bayer added a comment - This looks to be something with withEnv 's behavior. I'll look into it.
          Hide
          redeamer Michael Musenbrock added a comment -

          Same behavior with setting the PATH variable in the environment section, it does not seem to be passed to the 'sh' step. see https://issues.jenkins-ci.org/browse/JENKINS-45916?focusedCommentId=337539&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-337539

          Show
          redeamer Michael Musenbrock added a comment - Same behavior with setting the PATH variable in the environment section, it does not seem to be passed to the 'sh' step. see  https://issues.jenkins-ci.org/browse/JENKINS-45916?focusedCommentId=337539&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-337539

            People

            • Assignee:
              Unassigned
              Reporter:
              bkeyser_dgi Brian Keyser
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: