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

Empty environment variables are deleted

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • envinject-plugin
    • None
    • Jenkins core 1.560, EnvInject 1.89

      Empty environment variables are deleted. Three methods tried:

      1. Parameter
      2. Generate environment variables from script
      3. Inject environment variables to the build process

      As can be seen from the log below, the non-empty variables MYVAR1, MYVAR3 & MYVAR5 works as expected, but the empty variables MYVAR2, MYVAR4 & MYVAR6 are not present in the environment when the job executes.

      When looking at the enviroment through the left hand menu "Environment Variables" on the build page, all variables are present. You can actually also see that an implicit environment variable TEST_NODE is also deleted.

      I'm not sure that the problem is in EnvInject. Feel free to move it to some other component.

      Looks similar to JENKINS-15146.

      log:


      Started by user magjac
      [EnvInject] - Loading node environment variables.
      Building on master in workspace /srv/lhome/jenkins/jobs/empty_env_var_test/workspace
      [workspace] $ /bin/sh -xe /tmp/empty_env_var_test6599764777552559363.sh
      + echo MYVAR3=world
      + echo MYVAR4=
      [environment-script] Adding variable 'MYVAR4' with value ''
      [environment-script] Adding variable 'MYVAR3' with value 'world'
      [EnvInject] - Executing scripts and injecting environment variables after the SCM step.
      [EnvInject] - Injecting as environment variables the properties content
      MYVAR5=foo
      MYVAR6=

      [EnvInject] - Variables injected successfully.
      [workspace] $ /bin/sh -xe /tmp/hudson101371634758484537.sh
      + env
      JENKINS_HOME=/srv/lhome/jenkins
      MAIL=/var/mail/smoker
      USER=smoker
      LC_TIME=en_DK.UTF-8
      MYVAR1=hello
      SHLVL=1
      NODE_LABELS=master master_label null
      HUDSON_URL=http://smoketest.netinsight.se/jenkins/
      LD_LIBRARY_PATH=/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/server:/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64:/usr/lib/jvm/java-6-openjdk-amd64/jre/../lib/amd64
      MYVAR3=world
      HOME=/home/smoker
      BUILD_URL=http://smoketest.netinsight.se/jenkins/job/empty_env_var_test/6/
      MYVAR5=foo
      JENKINS_SERVER_COOKIE=dad1862e4df27e29
      HUDSON_COOKIE=0cebdd7b-7b7f-4962-a07c-c1dc9a842ca6
      LC_CTYPE=sv_SE.UTF-8
      WORKSPACE=/srv/lhome/jenkins/jobs/empty_env_var_test/workspace
      LOGNAME=smoker
      BUILD_CAUSE=MANUALTRIGGER
      _=/usr/bin/daemon
      EXECUTOR_NUMBER=380
      TERM=rxvt
      BUILD_DISPLAY_NAME=#6
      LC_COLLATE=sv_SE.UTF-8
      HUDSON_HOME=/srv/lhome/jenkins
      PATH=/home/smoker/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
      BUILD_ID=2014-08-15_11-35-11
      BUILD_TAG=jenkins-empty_env_var_test-6
      DISPLAY=worabu.netinsight.se:0.0
      JENKINS_URL=http://smoketest.netinsight.se/jenkins/
      PYTHONUSERBASE=/home/smoker/.local
      LANG=C
      JOB_URL=http://smoketest.netinsight.se/jenkins/job/empty_env_var_test/
      BUILD_NUMBER=6
      NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript
      SHELL=/bin/bash
      HUDSON_SERVER_COOKIE=dad1862e4df27e29
      LC_MEASUREMENT=sv_SE.UTF-8
      JOB_NAME=empty_env_var_test
      PWD=/srv/lhome/jenkins/jobs/empty_env_var_test/workspace
      LC_NUMERIC=sv_SE.UTF-8
      LC_PAPER=sv_SE.UTF-8
      BUILD_CAUSE_MANUALTRIGGER=true
      Finished: SUCCESS

      menu "Environment Variables":
      -----------------------------
      _ /usr/bin/daemon
      BUILD_CAUSE MANUALTRIGGER
      BUILD_CAUSE_MANUALTRIGGER true
      BUILD_DISPLAY_NAME #4
      BUILD_ID 2014-08-15_10-40-44
      BUILD_NUMBER 4
      BUILD_TAG jenkins-magjac-999-dev-smoke-fw025-nosa3-4
      BUILD_URL http://smoketest.netinsight.se/jenkins/job/magjac-999-dev-smoke-fw025-nosa3/4/
      BUILD_USER magjac
      BUILD_USER_FIRST_NAME magjac
      BUILD_USER_ID magjac
      CONFIG_FILE fw025.rc
      DISPLAY worabu.netinsight.se:0.0
      DO_COPY true
      DO_INSTALL false
      DO_PUBLISH false
      DO_TEST true
      EXECUTOR_NUMBER 324
      EXIT_ON_FAILURE false
      GIT_ROOT /home/magjac/git_repos2
      HOME /home/smoker
      HUDSON_HOME /srv/lhome/jenkins
      HUDSON_SERVER_COOKIE dad1862e4df27e29
      HUDSON_URL http://smoketest.netinsight.se/jenkins/
      JENKINS_HOME /srv/lhome/jenkins
      JENKINS_SERVER_COOKIE dad1862e4df27e29
      JENKINS_URL http://smoketest.netinsight.se/jenkins/
      JOB_NAME magjac-999-dev-smoke-fw025-nosa3
      JOB_URL http://smoketest.netinsight.se/jenkins/job/magjac-999-dev-smoke-fw025-nosa3/
      LANG C
      LC_COLLATE sv_SE.UTF-8
      LC_CTYPE sv_SE.UTF-8
      LC_MEASUREMENT sv_SE.UTF-8
      LC_NUMERIC sv_SE.UTF-8
      LC_PAPER sv_SE.UTF-8
      LC_TIME en_DK.UTF-8
      LD_LIBRARY_PATH /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/server:/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64:/usr/lib/jvm/java-6-openjdk-amd64/jre/../lib/amd64
      LOGNAME smoker
      MAIL /var/mail/smoker
      NETI_BUILDID testing
      NODE_LABELS master master_label null
      NODE_PATH /usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript
      PATH /home/smoker/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
      PWD /home/smoker
      PYTHONUSERBASE /home/smoker/.local
      SHELL /bin/bash
      SHLVL 1
      SUBSYSTEM nosa
      TERM rxvt
      TESTSUITE_RC testsuite.rc
      TRACK dev/smoke
      USER smoker
      WORKSPACE /srv/lhome/jenkins/jobs/magjac-999-dev-smoke-fw025-nosa3/workspace

      Configuration XML:
      ------------------
      <?xml version='1.0' encoding='UTF-8'?>
      <project>
      <actions/>
      <description></description>
      <keepDependencies>false</keepDependencies>
      <properties>
      <hudson.model.ParametersDefinitionProperty>
      <parameterDefinitions>
      <hudson.model.StringParameterDefinition>
      <name>MYVAR1</name>
      <description></description>
      <defaultValue>hello</defaultValue>
      </hudson.model.StringParameterDefinition>
      <hudson.model.StringParameterDefinition>
      <name>MYVAR2</name>
      <description></description>
      <defaultValue></defaultValue>
      </hudson.model.StringParameterDefinition>
      </parameterDefinitions>
      </hudson.model.ParametersDefinitionProperty>
      </properties>
      <scm class="hudson.scm.NullSCM"/>
      <canRoam>true</canRoam>
      <disabled>false</disabled>
      <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
      <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
      <triggers/>
      <concurrentBuild>false</concurrentBuild>
      <builders>
      <hudson.tasks.Shell>
      <command>env
      </command>
      </hudson.tasks.Shell>
      </builders>
      <publishers/>
      <buildWrappers>
      <com.lookout.jenkins.EnvironmentScript plugin="environment-script@1.1.2">
      <script>echo MYVAR3=world
      echo MYVAR4=""
      </script>
      <onlyRunOnParent>false</onlyRunOnParent>
      </com.lookout.jenkins.EnvironmentScript>
      <EnvInjectBuildWrapper plugin="envinject@1.89">
      <info>
      <propertiesContent>MYVAR5=foo
      MYVAR6=
      </propertiesContent>
      <loadFilesFromMaster>false</loadFilesFromMaster>
      </info>
      </EnvInjectBuildWrapper>
      </buildWrappers>
      </project>

            gbois Gregory Boissinot
            magjac Magnus Jacobsson
            Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: