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

injectedEnvVars.txt gets wiped empty when promoting build

    XMLWordPrintable

    Details

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

      Description

      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.

        Attachments

          Issue Links

            Activity

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

            Show
            dnusbaum 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.
            Hide
            scm_issue_link 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
            Show
            scm_issue_link 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
            Hide
            scm_issue_link 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)

            Also picks new Parent POM

            • Pick the released 1.27 version
            Show
            scm_issue_link 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
            Hide
            scm_issue_link 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)

            • Pick the released version of EnvInject API
            Show
            scm_issue_link 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
            Hide
            oleg_nenashev Oleg Nenashev added a comment -

            The fix has been released in 2.1.4

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

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: