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

injectedEnvVars.txt gets wiped empty when promoting build

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • envinject-plugin
    • None
    • Windows Server 2008 R2 (master)
      Jenkins v2.60.2
      Environment Injector Plugin v2.1.3
      promoted builds plugin v2.29
      Folders Plugin v6.1.0

      For some of our Jenkins jobs it happens that the builds irreversibly loose their injected environment variables when promoted. We see that the file injectedEnvVars.txt gets wiped empty, i.e. after triggering the promotion it has no contents anymore.

      Unfortunately, we have no clues what causes this issue. We do not get any hints from the Jenkins log. And we have other jobs with promotions where this does not happen. For the jobs where it happens the only common characteristic is that they reside in a folder. (Maybe this does not mean anything, but we never saw this issue happening for jobs not stored in a folder.) Update 2017-08-28: Today, I also saw this behaviour for a job not residing in a folder.

      Loosing the variables does not happen during the build steps of the promotion but immediately after starting the promotion, so it does not seem to be related to the actual contents of the promotion. When "debugging" this issue by removing promotion build contents step by step we finally ended up with the promotion not containing any build steps anymore but the contents of injectedEnvVars.txt were still deleted. (So it really looks like this issue has nothing to do with the build steps of the promotion, but with promotion itself.)

      That's all I can say – I am really sorry for not having more infomation about this.

       

      Note: We use promotions for various scenarios and in some we need to access the environment variables of a build. Here is an example: We have an artefact build job and after the artefacts have been tested successfully (by other Jenkins jobs) we have a promotion for packaging the artefacts into an installer (the promotion triggers another Jenkins job that does the packaging). This packaging job usually would use a groovy script for accessing the environment variables of the original artefact build job (collecting information like version numbers etc). This is how we realised that environement variables have been deleted, since the packaging job was not able to retrieve the environment variables anymore. As a workaround we now create and archive a properties file in the artefact build job which is later copied and injected by the packing job.

          [JENKINS-46479] injectedEnvVars.txt gets wiped empty when promoting build

          Devin Nusbaum added a comment - - edited

          Any instances of this bug that were caused by saving a deserialized build (which happens when a build is promoted after Jenkins is restarted) should be fixed by https://github.com/jenkinsci/envinject-lib/pull/11.

          If anyone has steps to reproduce that don't involve restarting Jenkins, please let me know.

          Devin Nusbaum added a comment - - edited Any instances of this bug that were caused by saving a deserialized build (which happens when a build is promoted after Jenkins is restarted) should be fixed by https://github.com/jenkinsci/envinject-lib/pull/11 . If anyone has steps to reproduce that don't involve restarting Jenkins, please let me know.

          Code changed in jenkins
          User: Devin Nusbaum
          Path:
          src/main/java/org/jenkinsci/lib/envinject/EnvInjectAction.java
          http://jenkins-ci.org/commit/envinject-lib/f4386942fc8a32d65f99fd974b9d337ecc508cfb
          Log:
          JENKINS-46479 Prevent environment variables from being deleted on existing builds (#11)

          • Load env vars from disk before saving so they aren't deleted if the cached value is wrong
          • Revert "Load env vars from disk before saving so they aren't deleted if the cached value is wrong"

          I think it is better to have onLoad intialize envMap and keep writeReplace the same. This reverts commit dab1c21d1a1b1e35cfdada95ec3ef3be77dc70e2.

          • Set envMap after the build is set in onLoad
          • Revert "Set envMap after the build is set in onLoad"

          This reverts commit faa98738e8355d80d52e796d0d2dcff03e71318e.

          • Revert "Revert "Load env vars from disk before saving so they aren't deleted if the cached value is wrong""

          This reverts commit 01dee1a5da0e3dc709223c56fc1193ce623c2b4f.

          • Cache the result of getEnvMap so we don't keep loading from disk

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Devin Nusbaum Path: src/main/java/org/jenkinsci/lib/envinject/EnvInjectAction.java http://jenkins-ci.org/commit/envinject-lib/f4386942fc8a32d65f99fd974b9d337ecc508cfb Log: JENKINS-46479 Prevent environment variables from being deleted on existing builds (#11) Load env vars from disk before saving so they aren't deleted if the cached value is wrong Revert "Load env vars from disk before saving so they aren't deleted if the cached value is wrong" I think it is better to have onLoad intialize envMap and keep writeReplace the same. This reverts commit dab1c21d1a1b1e35cfdada95ec3ef3be77dc70e2. Set envMap after the build is set in onLoad Revert "Set envMap after the build is set in onLoad" This reverts commit faa98738e8355d80d52e796d0d2dcff03e71318e. Revert "Revert "Load env vars from disk before saving so they aren't deleted if the cached value is wrong"" This reverts commit 01dee1a5da0e3dc709223c56fc1193ce623c2b4f. Cache the result of getEnvMap so we don't keep loading from disk

          Code changed in jenkins
          User: Oleg Nenashev
          Path:
          pom.xml
          http://jenkins-ci.org/commit/envinject-api-plugin/2084b69c751e4337a77468764844e5a2ad997df6
          Log:
          JENKINS-46479 - Update to EnvInject Lib 1.27 (#3)

          Also picks new Parent POM

          • Pick the released 1.27 version

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oleg Nenashev Path: pom.xml http://jenkins-ci.org/commit/envinject-api-plugin/2084b69c751e4337a77468764844e5a2ad997df6 Log: JENKINS-46479 - Update to EnvInject Lib 1.27 (#3) JENKINS-46479 - Update to EnvInject Lib 1.27 Also picks new Parent POM Pick the released 1.27 version

          Code changed in jenkins
          User: Oleg Nenashev
          Path:
          pom.xml
          http://jenkins-ci.org/commit/envinject-plugin/c0a2196e39c0ef2a5b02acde7b354582bdfdb7fa
          Log:
          JENKINS-46479 - Update to EnvInject API 1.3 (#126)

          • Pick the released version of EnvInject API

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oleg Nenashev Path: pom.xml http://jenkins-ci.org/commit/envinject-plugin/c0a2196e39c0ef2a5b02acde7b354582bdfdb7fa Log: JENKINS-46479 - Update to EnvInject API 1.3 (#126) JENKINS-46479 - Update too EnvInject API 1.3 Pick the released version of EnvInject API

          Oleg Nenashev added a comment -

          The fix has been released in 2.1.4

          Oleg Nenashev added a comment - The fix has been released in 2.1.4

            dnusbaum Devin Nusbaum
            cober Christoph Obermair
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: