Dynamically-scoped env step

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      Using

      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).

            Assignee:
            Jesse Glick
            Reporter:
            Jesse Glick
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: