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

env.WORKSPACE should be available within node{} in Pipeline

    Details

    • Similar Issues:

      Description

      Currently, the Snippet Generator reads: "The following variables are currently unavailable inside a Pipeline script: env.WORKSPACE".

      This seems like an easy limitation to overcome, by setting the env.WORKSPACE variable when executing within a node{} or ws{} block.

        Attachments

          Issue Links

            Activity

            Hide
            squalou squalou jenkins added a comment -

            on the prod environments :

            jenkins lts 2.7.2 (sidenote : even the 'lts' cycle has accelerated these times, just can't catch up the pace! 2.7.4 just released, we were about to update to .3)
            pipeline 2.2

            Show
            squalou squalou jenkins added a comment - on the prod environments : jenkins lts 2.7.2 (sidenote : even the 'lts' cycle has accelerated these times, just can't catch up the pace! 2.7.4 just released, we were about to update to .3) pipeline 2.2
            Hide
            jglick Jesse Glick added a comment - - edited
            env.WORKSPACE = pwd()
            

            should work in any environment, master or agent. It is not safe for use inside parallel branches, though, so it is better to use

            node {
              withEnv(["WORKSPACE=${pwd()}"]) {
                // …
              }
            }
            
            Show
            jglick Jesse Glick added a comment - - edited env.WORKSPACE = pwd() should work in any environment, master or agent. It is not safe for use inside parallel branches, though, so it is better to use node { withEnv([ "WORKSPACE=${pwd()}" ]) { // … } }
            Hide
            bitwiseman Liam Newman added a comment -

            Jesse Glick
            That doesn't sound like it is fixed then. If what you describe is true, shouldn't that "withEnv" be added to the node method in the core implementation? That would provide the "env.WORKSPACE" that the original description requested.

            Show
            bitwiseman Liam Newman added a comment - Jesse Glick That doesn't sound like it is fixed then. If what you describe is true, shouldn't that "withEnv" be added to the node method in the core implementation? That would provide the "env.WORKSPACE" that the original description requested.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            src/main/resources/org/jenkinsci/plugins/workflow/cps/EnvActionImpl/Binder/help.jelly
            http://jenkins-ci.org/commit/workflow-cps-plugin/b6fd3093c0cfb962f6562ec30b51efa500c721f3
            Log:
            JENKINS-33511 $WORKSPACE and $NODE_LABELS are now available.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/main/resources/org/jenkinsci/plugins/workflow/cps/EnvActionImpl/Binder/help.jelly http://jenkins-ci.org/commit/workflow-cps-plugin/b6fd3093c0cfb962f6562ec30b51efa500c721f3 Log: JENKINS-33511 $WORKSPACE and $NODE_LABELS are now available.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            src/main/resources/org/jenkinsci/plugins/workflow/cps/EnvActionImpl/Binder/help.jelly
            http://jenkins-ci.org/commit/workflow-cps-plugin/c10a8caa907e2452c83f2ef7fa54d81c6ac70654
            Log:
            Merge pull request #61 from jglick/WORKSPACE-JENKINS-33511

            JENKINS-33511 Doc update

            Compare: https://github.com/jenkinsci/workflow-cps-plugin/compare/b5b1ed0d06aa...c10a8caa907e

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/main/resources/org/jenkinsci/plugins/workflow/cps/EnvActionImpl/Binder/help.jelly http://jenkins-ci.org/commit/workflow-cps-plugin/c10a8caa907e2452c83f2ef7fa54d81c6ac70654 Log: Merge pull request #61 from jglick/WORKSPACE- JENKINS-33511 JENKINS-33511 Doc update Compare: https://github.com/jenkinsci/workflow-cps-plugin/compare/b5b1ed0d06aa...c10a8caa907e

              People

              • Assignee:
                jglick Jesse Glick
                Reporter:
                apemberton Andy Pemberton
              • Votes:
                23 Vote for this issue
                Watchers:
                36 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: