Details

    • Type: New Feature
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: pipeline
    • Labels:
      None
    • Similar Issues:

      Description

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

        Attachments

          Issue Links

            Activity

            Hide
            jglick Jesse Glick added a comment -

            If adding this step (and I think withEnv is a better name—no clash with the variable), the help text from JENKINS-27145 would probably have a better home.

            Show
            jglick Jesse Glick added a comment - If adding this step (and I think withEnv is a better name—no clash with the variable), the help text from JENKINS-27145 would probably have a better home.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            CHANGES.md
            aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/EnvStepTest.java
            basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/EnvStep.java
            basic-steps/src/main/resources/org/jenkinsci/plugins/workflow/steps/EnvStep/config.jelly
            basic-steps/src/test/java/org/jenkinsci/plugins/workflow/steps/EnvStepTest.java
            http://jenkins-ci.org/commit/workflow-plugin/cd30c066b3d21b735a6c76b6e43e555dc2930077
            Log:
            [FIXED JENKINS-26128] Added withEnv step.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: CHANGES.md aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/EnvStepTest.java basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/EnvStep.java basic-steps/src/main/resources/org/jenkinsci/plugins/workflow/steps/EnvStep/config.jelly basic-steps/src/test/java/org/jenkinsci/plugins/workflow/steps/EnvStepTest.java http://jenkins-ci.org/commit/workflow-plugin/cd30c066b3d21b735a6c76b6e43e555dc2930077 Log: [FIXED JENKINS-26128] Added withEnv step.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            CHANGES.md
            TUTORIAL.md
            aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/EnvStepTest.java
            basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/EnvStep.java
            basic-steps/src/main/resources/org/jenkinsci/plugins/workflow/steps/EnvStep/config.groovy
            basic-steps/src/main/resources/org/jenkinsci/plugins/workflow/steps/EnvStep/help-overrides.html
            basic-steps/src/main/resources/org/jenkinsci/plugins/workflow/steps/EnvStep/help.html
            basic-steps/src/test/java/org/jenkinsci/plugins/workflow/steps/EnvStepTest.java
            cps/src/main/java/org/jenkinsci/plugins/workflow/cps/EnvActionImpl.java
            cps/src/main/resources/org/jenkinsci/plugins/workflow/cps/CpsFlowDefinition/help-script.html
            step-api/src/main/java/org/jenkinsci/plugins/workflow/steps/BodyInvoker.java
            step-api/src/main/java/org/jenkinsci/plugins/workflow/steps/EnvironmentExpander.java
            step-api/src/test/java/org/jenkinsci/plugins/workflow/steps/StepConfigTester.java
            support/src/main/java/org/jenkinsci/plugins/workflow/support/DefaultStepContext.java
            http://jenkins-ci.org/commit/workflow-plugin/42805fed800b4a9865a9d1edb1e3dd7688a3f1ba
            Log:
            Merge pull request #104 from jglick/withEnv-JENKINS-26128

            JENKINS-26128 withEnv

            Compare: https://github.com/jenkinsci/workflow-plugin/compare/205f27b05941...42805fed800b

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: CHANGES.md TUTORIAL.md aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/EnvStepTest.java basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/EnvStep.java basic-steps/src/main/resources/org/jenkinsci/plugins/workflow/steps/EnvStep/config.groovy basic-steps/src/main/resources/org/jenkinsci/plugins/workflow/steps/EnvStep/help-overrides.html basic-steps/src/main/resources/org/jenkinsci/plugins/workflow/steps/EnvStep/help.html basic-steps/src/test/java/org/jenkinsci/plugins/workflow/steps/EnvStepTest.java cps/src/main/java/org/jenkinsci/plugins/workflow/cps/EnvActionImpl.java cps/src/main/resources/org/jenkinsci/plugins/workflow/cps/CpsFlowDefinition/help-script.html step-api/src/main/java/org/jenkinsci/plugins/workflow/steps/BodyInvoker.java step-api/src/main/java/org/jenkinsci/plugins/workflow/steps/EnvironmentExpander.java step-api/src/test/java/org/jenkinsci/plugins/workflow/steps/StepConfigTester.java support/src/main/java/org/jenkinsci/plugins/workflow/support/DefaultStepContext.java http://jenkins-ci.org/commit/workflow-plugin/42805fed800b4a9865a9d1edb1e3dd7688a3f1ba Log: Merge pull request #104 from jglick/withEnv- JENKINS-26128 JENKINS-26128 withEnv Compare: https://github.com/jenkinsci/workflow-plugin/compare/205f27b05941...42805fed800b
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/CoreWrapperStepTest.java
            basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/CoreWrapperStep.java
            http://jenkins-ci.org/commit/workflow-plugin/932adc8fd4a0c3b73cce54a657da2b7e7f985db1
            Log:
            JENKINS-26128 Demonstrating that non-block-scoped env sets are shadowed by block context.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/CoreWrapperStepTest.java basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/CoreWrapperStep.java http://jenkins-ci.org/commit/workflow-plugin/932adc8fd4a0c3b73cce54a657da2b7e7f985db1 Log: JENKINS-26128 Demonstrating that non-block-scoped env sets are shadowed by block context.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/CoreWrapperStepTest.java
            basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/CoreWrapperStep.java
            http://jenkins-ci.org/commit/workflow-basic-steps-plugin/711927d659eca5c74dcf7dc3267a080c3377eda3
            Log:
            JENKINS-26128 Demonstrating that non-block-scoped env sets are shadowed by block context.

            Originally-Committed-As: 932adc8fd4a0c3b73cce54a657da2b7e7f985db1

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/CoreWrapperStepTest.java basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/CoreWrapperStep.java http://jenkins-ci.org/commit/workflow-basic-steps-plugin/711927d659eca5c74dcf7dc3267a080c3377eda3 Log: JENKINS-26128 Demonstrating that non-block-scoped env sets are shadowed by block context. Originally-Committed-As: 932adc8fd4a0c3b73cce54a657da2b7e7f985db1
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/EnvStepTest.java
            basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/EnvStep.java
            basic-steps/src/test/java/org/jenkinsci/plugins/workflow/steps/EnvStepTest.java
            http://jenkins-ci.org/commit/workflow-basic-steps-plugin/31b8af7404589d1908f18b0586fdeda183ab7a8c
            Log:
            [FIXED JENKINS-26128] Added withEnv step.
            Originally-Committed-As: cd30c066b3d21b735a6c76b6e43e555dc2930077

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: aggregator/src/test/java/org/jenkinsci/plugins/workflow/steps/EnvStepTest.java basic-steps/src/main/java/org/jenkinsci/plugins/workflow/steps/EnvStep.java basic-steps/src/test/java/org/jenkinsci/plugins/workflow/steps/EnvStepTest.java http://jenkins-ci.org/commit/workflow-basic-steps-plugin/31b8af7404589d1908f18b0586fdeda183ab7a8c Log: [FIXED JENKINS-26128] Added withEnv step. Originally-Committed-As: cd30c066b3d21b735a6c76b6e43e555dc2930077
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            basic-steps/src/test/java/org/jenkinsci/plugins/workflow/steps/EnvStepTest.java
            http://jenkins-ci.org/commit/workflow-scm-step-plugin/2536096c09dfde3eb032c3c76fecded02e67cc3a
            Log:
            [FIXED JENKINS-26128] Added withEnv step.
            Originally-Committed-As: cd30c066b3d21b735a6c76b6e43e555dc2930077

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: basic-steps/src/test/java/org/jenkinsci/plugins/workflow/steps/EnvStepTest.java http://jenkins-ci.org/commit/workflow-scm-step-plugin/2536096c09dfde3eb032c3c76fecded02e67cc3a Log: [FIXED JENKINS-26128] Added withEnv step. Originally-Committed-As: cd30c066b3d21b735a6c76b6e43e555dc2930077
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            basic-steps/src/test/java/org/jenkinsci/plugins/workflow/steps/EnvStepTest.java
            http://jenkins-ci.org/commit/workflow-multibranch-plugin/cc3aba5ff5a430ca7bb0059e3483013c6aa7a85e
            Log:
            [FIXED JENKINS-26128] Added withEnv step.
            Originally-Committed-As: cd30c066b3d21b735a6c76b6e43e555dc2930077

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: basic-steps/src/test/java/org/jenkinsci/plugins/workflow/steps/EnvStepTest.java http://jenkins-ci.org/commit/workflow-multibranch-plugin/cc3aba5ff5a430ca7bb0059e3483013c6aa7a85e Log: [FIXED JENKINS-26128] Added withEnv step. Originally-Committed-As: cd30c066b3d21b735a6c76b6e43e555dc2930077

              People

              • Assignee:
                jglick Jesse Glick
                Reporter:
                jglick Jesse Glick
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: