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

Dynamically-scoped env step


    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Major Major
    • pipeline
    • None


      env.PATH="${tool 'Maven'}/bin:${env.PATH}"

      works fine if you are only using only slave, or even if you have several but are using them serially. But it would not work when running things in parallel on several slaves (with different installation locations).

      For that case it would be better to write something like

      node {
          env("PATH=${tool 'Maven'}/bin:${env.PATH}") {
              // ...
              sh 'mvn install'
              // ...

      where the block step would temporarily override one (or more?) environment variables, but only in that thread. (These would presumably not be exposed via the REST API.)

      The workaround is to define the environment variable in each sh or similar step, or do without it (in this example by giving an absolute executable name).

            jglick Jesse Glick
            jglick Jesse Glick
            0 Vote for this issue
            4 Start watching this issue