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

EnvInject Undefines Jenkins Global properties referencing WORKSPACE variable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • envinject-plugin
    • None
    • Linux lc-irv-1231 2.6.9-89.0.9.ELsmp #1 SMP Wed Aug 19 08:06:10 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux

      Jenkins 1.486
      envinject 1.72

      In my jenkins configuration for "Global properties", I have a property TEST_WORKSPACE defined as ${WORKSPACE}.

      Then in my jenkins job I have "prepare an environment for the run" defined to a file which does not set TEST_WORKSPACE or WORKSPACE.

      But, when I run the job, TEST_WORKSPACE is not defined in console, I get this:

      [EnvInject] - Loading node environment variables.
      [EnvInject] - Preparing an environment for the build.
      [EnvInject] - Keeping Jenkins system variables.
      [EnvInject] - Keeping Jenkins build variables.
      [EnvInject] - Adding build parameters as variables.
      [EnvInject] - Injecting as environment variables the properties file path '/home/jims/global.prop'
      [EnvInject] - Variables injected successfully.
      [EnvInject] - Injecting contributions.
      Building on master in workspace /projects/BCMQUAL/jenkins_test/jobs/test-envinject/workspace
      [workspace] $ /bin/sh -x /tmp/hudson3013573853871224155.sh
      + echo 'WORKSPACE = /projects/BCMQUAL/jenkins_test/jobs/test-envinject/workspace'
      WORKSPACE = /projects/BCMQUAL/jenkins_test/jobs/test-envinject/workspace
      + echo 'TEST_WORKSPACE = '
      TEST_WORKSPACE =
      Notifying upstream projects of job completion
      Finished: SUCCESS

      If I revert back to envinject 1.36, then it is defined and I see this in the console:

      [EnvInject] - Preparing an environment for the job.
      [EnvInject] - Keep Jenkins system variables.
      [EnvInject] - Keep Jenkins build variables.
      [EnvInject] - Injecting as environment variables the properties file path '/home/jims/global.prop'
      [EnvInject] - Variables injected successfully.
      [EnvInject] - Unset unresolved 'TEST_WORKSPACE' variable.
      Building on master in workspace /projects/BCMQUAL/jenkins_test/jobs/test-envinject/workspace
      [workspace] $ /bin/sh -x /tmp/hudson3503397345619621354.sh
      + echo 'WORKSPACE = /projects/BCMQUAL/jenkins_test/jobs/test-envinject/workspace'
      WORKSPACE = /projects/BCMQUAL/jenkins_test/jobs/test-envinject/workspace
      + echo 'TEST_WORKSPACE = /projects/BCMQUAL/jenkins_test/jobs/test-envinject/workspace'
      TEST_WORKSPACE = /projects/BCMQUAL/jenkins_test/jobs/test-envinject/workspace
      Notifying upstream projects of job completion
      Finished: SUCCESS

          [JENKINS-15658] EnvInject Undefines Jenkins Global properties referencing WORKSPACE variable

          Gregory Boissinot added a comment - - edited

          I'm looking at a potential regression between versions.
          However, WORKSPACE variable is only available for job instance. Therefore, the variable is unknown at global level.

          Gregory Boissinot added a comment - - edited I'm looking at a potential regression between versions. However, WORKSPACE variable is only available for job instance. Therefore, the variable is unknown at global level.

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

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Gregory Boissinot Path: src/main/java/org/jenkinsci/plugins/envinject/EnvInjectListener.java src/main/java/org/jenkinsci/plugins/envinject/service/EnvInjectEnvVars.java http://jenkins-ci.org/commit/envinject-plugin/b1d9dbeaade4f04d624a76b308843a94b575b9ae Log: Fix JENKINS-15658

          I fixed the solution by the authorisation of having a global TEST WORKSPACE variable and it is resolved at runtime at job level.
          Please could you check if it suits you?
          Waiting for your review, I'll add a regression test.

          Gregory Boissinot added a comment - I fixed the solution by the authorisation of having a global TEST WORKSPACE variable and it is resolved at runtime at job level. Please could you check if it suits you? Waiting for your review, I'll add a regression test.

          Jim Searle added a comment -

          Thanks! Where do I get the new version of the plugin?

          Jim Searle added a comment - Thanks! Where do I get the new version of the plugin?

          You can build the plugin from the source here
          https://github.com/jenkinsci/envinject-plugin

          or you can download the last hpi file from the last commit build here
          https://buildhive.cloudbees.com/job/jenkinsci/job/envinject-plugin/ws/target/

          Gregory Boissinot added a comment - You can build the plugin from the source here https://github.com/jenkinsci/envinject-plugin or you can download the last hpi file from the last commit build here https://buildhive.cloudbees.com/job/jenkinsci/job/envinject-plugin/ws/target/

          Jim Searle added a comment -

          That fixed it. Thanks!

          Jim Searle added a comment - That fixed it. Thanks!

          Code changed in jenkins
          User: Gregory Boissinot
          Path:
          src/main/java/org/jenkinsci/plugins/envinject/EnvInjectJobProperty.java
          src/main/java/org/jenkinsci/plugins/envinject/EnvInjectJobPropertyInfo.java
          src/test/java/org/jenkinsci/plugins/envinject/GlobalPropertiesTest.java
          http://jenkins-ci.org/commit/envinject-plugin/be86097a4ebf373d4874cc5e89e89fd250bf3a01
          Log:
          Add a regression test to fix JENKINS-15658

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Gregory Boissinot Path: src/main/java/org/jenkinsci/plugins/envinject/EnvInjectJobProperty.java src/main/java/org/jenkinsci/plugins/envinject/EnvInjectJobPropertyInfo.java src/test/java/org/jenkinsci/plugins/envinject/GlobalPropertiesTest.java http://jenkins-ci.org/commit/envinject-plugin/be86097a4ebf373d4874cc5e89e89fd250bf3a01 Log: Add a regression test to fix JENKINS-15658

          I am having similar problem with $PATH which is modified in global environment vars config but it is cleared after injecting the environment vars on the build

          Waleed gadelkareem added a comment - I am having similar problem with $PATH which is modified in global environment vars config but it is cleared after injecting the environment vars on the build

            gbois Gregory Boissinot
            jimsearle Jim Searle
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: