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

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

    XMLWordPrintable

Details

    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

            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

            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
            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()}"]) {
                // …
              }
            }
            
            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()}" ]) { // … } }
            bitwiseman Liam Newman added a comment -

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

            bitwiseman Liam Newman added a comment - jglick 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.

            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.

            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.

            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

            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

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

              Dates

                Created:
                Updated:
                Resolved: