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

Can't set custom variable in customWorkspace

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • core, pipeline

      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!

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

              Created:
              Updated: