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

Can't set custom variable in customWorkspace

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Component/s: core, pipeline
    • Environment:
    • Similar Issues:

      Description

      Hello,

      I would like to use my own environment variable to set the customWorkspace.
      Unfortunately, the customWorkspace seems to resolve only built-in Jenkins variables, like JOB_NAME or JOB_BASE_NAME.

      See below, the pipeline I am trying to execute:  

      pipeline {
      
        environment {
          CUSTOM_VAR = 'dev1'
        }
        
         agent {
          node {
            label ''
            customWorkspace "/var/lib/jenkins/workspace/${CUSTOM_VAR}"
           }
         }
      
        stages {
      
           stage ('Print CUSTOM_VAR') {
             steps {
             sh 'printenv'
             sh 'echo "$CUSTOM_VAR"'
          }
          }
         }
      }
       

      This pipeline is throwing the error:
      [Pipeline] End of Pipelinegroovy.lang.MissingPropertyException: No such property: CUSTOM_VAR for class: groovy.lang.Binding
      at groovy.lang.Binding.getVariable(Binding.java:63)

      Thank you!

        Attachments

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              Unassigned
              Reporter:
              benfab Benoit Fabre
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: