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

EnvInject Undefines Jenkins Global properties referencing WORKSPACE variable

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: envinject-plugin
    • Labels:
      None
    • Environment:
      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
    • Similar Issues:

      Description

      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

        Attachments

          Activity

          Hide
          gbois 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.

          Show
          gbois 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.
          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/EnvInjectListener.java
          src/main/java/org/jenkinsci/plugins/envinject/service/EnvInjectEnvVars.java
          http://jenkins-ci.org/commit/envinject-plugin/b1d9dbeaade4f04d624a76b308843a94b575b9ae
          Log:
          Fix JENKINS-15658

          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/EnvInjectListener.java src/main/java/org/jenkinsci/plugins/envinject/service/EnvInjectEnvVars.java http://jenkins-ci.org/commit/envinject-plugin/b1d9dbeaade4f04d624a76b308843a94b575b9ae Log: Fix JENKINS-15658
          Hide
          gbois 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.

          Show
          gbois 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.
          Hide
          jimsearle Jim Searle added a comment -

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

          Show
          jimsearle Jim Searle added a comment - Thanks! Where do I get the new version of the plugin?
          Hide
          gbois 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/

          Show
          gbois 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/
          Hide
          jimsearle Jim Searle added a comment -

          That fixed it. Thanks!

          Show
          jimsearle Jim Searle added a comment - That fixed it. Thanks!
          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/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

          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/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
          Hide
          gadelkareem 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

          Show
          gadelkareem 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

            People

            • Assignee:
              gbois Gregory Boissinot
              Reporter:
              jimsearle Jim Searle
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: