In order to support a number of use cases, we need a way to define variables that can be accessed across different steps blocks.

      As a talking point, here's what someone was trying to do:

      pipeline {
        agent {
          node label: 'master'
        }
        stages {
          stage('Allocate workspace') {
            steps {
              script {
                def extWorkspace = exwsAllocate 'diskpool1'
              }
            }
          }
          stage('Build') {
            steps {
              parallel(
                "a": {
                  node(label: 'a') {
                    exws (extWorkspace) {
                      sh 'ls -la'
                    }
                  }
                },
                "b": {
                  node(label: 'b') {
                    exws (extWorkspace) {
                      sh 'ls -la'
                    }
                  }
                }
              )
            }
          }
        }
      }
      

          [JENKINS-43408] Provide a standardized way of dealing with variables

          Patrick Wolf added a comment -

          kzantow That would work if you define extWorkspace as an environment variable instead of a groovy variable.

          Patrick Wolf added a comment - kzantow That would work if you define extWorkspace as an environment variable instead of a groovy variable.

          Keith Zantow added a comment -

          hrmpw but it's calling `exwsAllocate`, which would have to happen in context of an agent, right?

          Keith Zantow added a comment - hrmpw but it's calling `exwsAllocate`, which would have to happen in context of an agent, right?

          Patrick Wolf added a comment -

          I'm not familiar with that method, kzantow. Does it require a workspace to run on?

          You can always do 

          script {
                    env.extWorkspace = exwsAllocate 'diskpool1'
                  }
          

          assuming, of course, that it returns a string.

          Patrick Wolf added a comment - I'm not familiar with that method, kzantow . Does it require a workspace to run on? You can always do  script { env.extWorkspace = exwsAllocate 'diskpool1' } assuming, of course, that it returns a string.

            kzantow Keith Zantow
            kzantow Keith Zantow
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: