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

EnvJect unsets empty string properties returned in maps

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reopened (View Workflow)
    • Priority: Blocker
    • Resolution: Unresolved
    • Component/s: envinject-plugin
    • Labels:
      None
    • Environment:
      1.69, 1.92.1
    • Similar Issues:

      Description

      EnvJect unsets empty and whitespace properties

      Example
      return ["LABEL":" ",ANOTHER_LABEL:""]

      [EnvInject] - Unset unresolved 'ANOTHER_LABEL' variable.
      [EnvInject] - Unset unresolved 'LABEL' variable.

      It appears that the fix for JENKINS-14930 caused the problem.

      Unsetting blank variables should be optional.

        Attachments

          Issue Links

            Activity

            Hide
            jbochenski Jakub Bochenski added a comment -

            I'm getting the same behaviour (blank properties are not set) in 1.92.1

            Show
            jbochenski Jakub Bochenski added a comment - I'm getting the same behaviour (blank properties are not set) in 1.92.1
            Hide
            think think think added a comment -

            it's still not possible to have an empty Environment variable.
            Using pipeline step withEnv(['FOO=']) with result in key="FOO" and value="".
            Then EnvVars.override is called and even removes "FOO" from Environment.

            https://github.com/kohsuke/hudson/blob/master/core/src/main/java/hudson/EnvVars.java#L126

            if(value==null || value.length()==0) {
                remove(key);
                return;
            }
            

            The behavior would be okay, if the value is null. But for an explicit empty String it seems not reasonable, that the Key is deleted.

            What needs to be done to change this? It could not be done in the withEnv Code except in dirty ways.

            Show
            think think think added a comment - it's still not possible to have an empty Environment variable. Using pipeline step withEnv( ['FOO='] ) with result in key="FOO" and value="". Then EnvVars.override is called and even removes "FOO" from Environment. https://github.com/kohsuke/hudson/blob/master/core/src/main/java/hudson/EnvVars.java#L126 if (value== null || value.length()==0) { remove(key); return ; } The behavior would be okay, if the value is null. But for an explicit empty String it seems not reasonable, that the Key is deleted. What needs to be done to change this? It could not be done in the withEnv Code except in dirty ways.
            Hide
            tisis2 Dominik Gabriel added a comment -

            we use it for parameters to give the starter of a job the possibility to extend an existing path with a subpath. if the starter wants to use the root he wont type anything for this parameter... this doesn't work anymore...

            Show
            tisis2 Dominik Gabriel added a comment - we use it for parameters to give the starter of a job the possibility to extend an existing path with a subpath. if the starter wants to use the root he wont type anything for this parameter... this doesn't work anymore...
            Hide
            jglick Jesse Glick added a comment -

            think think Pipeline does not use EnvInject so any Pipeline bug should be filed separately with steps to reproduce from scratch, in workflow-plugin.

            Show
            jglick Jesse Glick added a comment - think think Pipeline does not use EnvInject so any Pipeline bug should be filed separately with steps to reproduce from scratch, in workflow-plugin .
            Hide
            lisheng Jason Zheng added a comment -

            I want to set a environment variable to an empty string ("") via withEnv(), but it seems not working.

            Show
            lisheng Jason Zheng added a comment - I want to set a environment variable to an empty string ("") via withEnv(), but it seems not working.

              People

              • Assignee:
                gbois Gregory Boissinot
                Reporter:
                jmaxwell Jeff Maxwell
              • Votes:
                5 Vote for this issue
                Watchers:
                14 Start watching this issue

                Dates

                • Created:
                  Updated: