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

Environment section of Declarative pipelines does not allow setting of blank strings

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      When setting an environment variable equal to a blank string it comes back a the literal string of `null` instead of being a blank string

      Steps to reproduce:

      1. Create a new pipeline job with the following definition:
        pipeline {
            agent any
            environment {
                VERSION_SUFFIX = ''
            }
            stages {
                stage("test") {
                    steps{
                        echo "env.VERSION_SUFFIX = ${env.VERSION_SUFFIX}"
                    }
                }
            }
        }
        
      1. Run said pipeline
      2. Observe the output is `
        env.VERSION_SUFFIX = null

      Expected result:

      Normally I would expect it to just be a blank string or nothing there

        Attachments

          Activity

          Hide
          alexanderrtaylor Alex Taylor added a comment -

          Is it related to this? https://github.com/jenkinsci/pipeline-model-definition-plugin/blob/7502d14aa4db891302abf48a2c7de7c9ced97f95/pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Environment.groovy#L124

           

          I know that is resolving the env variable but I did not think groovy/java would think a blank string is the same as null so I was confused

          Show
          alexanderrtaylor Alex Taylor added a comment - Is it related to this? https://github.com/jenkinsci/pipeline-model-definition-plugin/blob/7502d14aa4db891302abf48a2c7de7c9ced97f95/pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Environment.groovy#L124   I know that is resolving the env variable but I did not think groovy/java would think a blank string is the same as null so I was confused

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            alexanderrtaylor Alex Taylor
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: