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

Environment Variable Injection doesn't work when project run on slave node that sets the same variable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Component/s: envinject-plugin
    • Labels:
      None

      Description

      When a slave node is configured to append/prepend to a variable (Node Properties->Environment Variables) that is used by EnvInject within a job, the injection fails. If the slave node simply sets the variable (i.e. doesn't reference the same variable in the act of setting) it works fine. Consider the following job, which has a single build step: echo $PATH
      In Build Environment->Inject, there is a single line in the properties content box: PATH=/opt/bin:$PATH

      That's the job. Now, the slave node, also sets the PATH variable. Let's first look at a working example, where the slave node sets PATH to: /data/goesrsw/goesr/bin Here is the output:
      [EnvInject] - Executing scripts and injecting environment variables after the SCM step.
      [EnvInject] - Injecting as environment variables the properties content
      PATH=/opt/bin:$PATH

      [EnvInject] - Variables injected successfully.
      [aaa] $ bash -xe /tmp/hudson5838824311735104563.sh
      + echo /opt/bin:/data/goesrsw/goesr/bin
      /opt/bin:/data/goesrsw/goesr/bin
      Notifying upstream projects of job completion
      Finished: SUCCESS

      Ok, so to demonstrate the problem, change the PATH in the slave node to: /data/goesrsw/goesr/bin:$PATH
      Now, here's the output:
      [EnvInject] - Executing scripts and injecting environment variables after the SCM step.
      [EnvInject] - Injecting as environment variables the properties content
      PATH=/opt/bin:$PATH

      [EnvInject] - Variables injected successfully.
      [EnvInject] - Unset unresolved 'PATH' variable.
      [aaa] $ bash -xe /tmp/hudson3276485997068093627.sh
      + echo /data/goesrsw/goesr/bin:/data/goesrsw/goesr/bin:/data/goesrsw/goesr/bin:/home/goesrjen/bin:/usr/local/bin:/usr/local/sbin:/app/share/bin:/app/share/sbin:/usr/bin/X11:/bin:/usr/bin:/sbin:/usr/sbin:.:/app/rc52_test1_perl:/data/goesrsw/WindRiver/gnu/4.1.2-vxworks-6.6/x86-linux2/bin:/data/goesrsw/WindRiver/workbench-3.0/x86-linux2/bin:/data/goesrsw/WindRiver/workbench-3.0/foundation/4.1.1/x86-linux2/lib/tcl8.4/Wind
      /data/goesrsw/goesr/bin:/data/goesrsw/goesr/bin:/data/goesrsw/goesr/bin:/home/goesrjen/bin:/usr/local/bin:/usr/local/sbin:/app/share/bin:/app/share/sbin:/usr/bin/X11:/bin:/usr/bin:/sbin:/usr/sbin:.:/app/rc52_test1_perl:/data/goesrsw/WindRiver/gnu/4.1.2-vxworks-6.6/x86-linux2/bin:/data/goesrsw/WindRiver/workbench-3.0/x86-linux2/bin:/data/goesrsw/WindRiver/workbench-3.0/foundation/4.1.1/x86-linux2/lib/tcl8.4/Wind
      Notifying upstream projects of job completion
      Finished: SUCCESS

      As you can see, the injection didn't work. /opt/bin is nowhere to be found.

      1. aaa.job.config.xml
        1 kB
        Josh Davidson
      2. config.xml
        24 kB
        Josh Davidson

        Activity

        Hide
        gbois Gregory Boissinot added a comment -

        To make sure to reproduce the issue, could you attach your job configuration file and your global infrastructure configuration file ($JENKINS_HOME/config.xml and $JENKINS_HOME/jobs/<job_name>/config.xml)?

        Show
        gbois Gregory Boissinot added a comment - To make sure to reproduce the issue, could you attach your job configuration file and your global infrastructure configuration file ($JENKINS_HOME/config.xml and $JENKINS_HOME/jobs/<job_name>/config.xml)?
        Hide
        davidsj2 Josh Davidson added a comment -

        Config files posted.

        Show
        davidsj2 Josh Davidson added a comment - Config files posted.
        Hide
        scm_issue_link SCM/JIRA link daemon added a comment -

        Code changed in jenkins
        User: Gregory Boissinot
        Path:
        src/main/java/org/jenkinsci/plugins/envinject/EnvInjectComputerListener.java
        src/main/java/org/jenkinsci/plugins/envinject/EnvInjectListener.java
        src/main/java/org/jenkinsci/plugins/envinject/service/EnvInjectEnvVars.java
        src/main/java/org/jenkinsci/plugins/envinject/service/EnvInjectVariableGetter.java
        http://jenkins-ci.org/commit/envinject-plugin/33662e748adf063a00c7387d2231e747221ea0d0
        Log:
        Fix JENKINS-13085

        Show
        scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Gregory Boissinot Path: src/main/java/org/jenkinsci/plugins/envinject/EnvInjectComputerListener.java src/main/java/org/jenkinsci/plugins/envinject/EnvInjectListener.java src/main/java/org/jenkinsci/plugins/envinject/service/EnvInjectEnvVars.java src/main/java/org/jenkinsci/plugins/envinject/service/EnvInjectVariableGetter.java http://jenkins-ci.org/commit/envinject-plugin/33662e748adf063a00c7387d2231e747221ea0d0 Log: Fix JENKINS-13085
        Hide
        gbois Gregory Boissinot added a comment -

        Thanks for your inputs.
        Version 1.37 should fix it.

        Show
        gbois Gregory Boissinot added a comment - Thanks for your inputs. Version 1.37 should fix it.

          People

          • Assignee:
            gbois Gregory Boissinot
            Reporter:
            davidsj2 Josh Davidson
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: