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

Folder properties not available in declarative environment step

      Folder properties set on an Organization Folder project is not available in the "environment" step

      With the following property set:
      Name: TEST_VAR
      Value: TRUE

      pipeline {
          agent none
      
          options {
              withFolderProperties()
          }
      
          environment {
              IS_SET = "${env.TEST_VAR}"
          }
      
          stages {
              stage ('Test')
              {
                  agent any
                  steps {
                      echo "TEST_VAR: ${env.TEST_VAR}!!!"
                      echo "IS_SET: ${env.IS_SET }!!!"
                  }
              }
          }
      }
      

      I get the following result:

      [Pipeline] echo
      TEST_VAR: TRUE!!!
      [Pipeline] echo
      IS_SET  : null!!!
      

          [JENKINS-68522] Folder properties not available in declarative environment step

          Mark Waite added a comment -

          Issue is still present in most recent release of the plugin. Does not require an organization folder. I see it with a folder that has a property A_PROPERTY with value 'A' and the following declarative Pipeline fails:

          pipeline {
              agent any
              options {
                  withFolderProperties()
              }
              environment {
                  hasProperty = "abc${A_PROPERTY}"
              }
              stages {
                  stage('Hello') {
                      steps {
                          echo 'Hello World'
                          echo "A_PROPERTY IS ${A_PROPERTY} and hasProperty is ${hasProperty}"
                          echo "A_PROPERTY IS ${env.A_PROPERTY}"
                          sh 'echo A_PROPERTY is $A_PROPERTY | grep -w A'
                          // Job will fail here because hasProperty is abcnull
                          sh 'echo hasProperty is $hasProperty | grep -w abcA'
                      }
                  }
              }
          }
          

          Mark Waite added a comment - Issue is still present in most recent release of the plugin. Does not require an organization folder. I see it with a folder that has a property A_PROPERTY with value 'A' and the following declarative Pipeline fails: pipeline { agent any options { withFolderProperties() } environment { hasProperty = "abc${A_PROPERTY}" } stages { stage( 'Hello' ) { steps { echo 'Hello World' echo "A_PROPERTY IS ${A_PROPERTY} and hasProperty is ${hasProperty}" echo "A_PROPERTY IS ${env.A_PROPERTY}" sh 'echo A_PROPERTY is $A_PROPERTY | grep -w A' // Job will fail here because hasProperty is abcnull sh 'echo hasProperty is $hasProperty | grep -w abcA' } } } }

            Unassigned Unassigned
            carelc Carel Combrink
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: