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

java.lang.NullPointerException in EnvInjectAction.writeReplace

    • Icon: Bug Bug
    • Resolution: Postponed
    • Icon: Critical Critical
    • multijob-plugin
    • None
    • Jenkins ver. 2.73.2
      envinject plugin 2.1.5

      java.lang.NullPointerException
       at org.jenkinsci.lib.envinject.EnvInjectAction.writeReplace(EnvInjectAction.java:144)
       at sun.reflect.GeneratedMethodAccessor369.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:498)
       at com.thoughtworks.xstream.converters.reflection.SerializationMethodInvoker.callWriteReplace(SerializationMethodInvoker.java:89)
       at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:141)
       at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
       at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
       at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
       at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88)
       at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:64)
       at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:74)
       at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
       at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
       at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
       at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265)
       at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252)
       at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
       at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
       at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
       at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
       at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
       at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
       at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
       at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265)
       at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252)
       at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
       at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
       at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
       at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
       at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
       at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
       at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
       at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88)
       at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:64)
       at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:74)
       at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
       at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
       at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
       at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265)
       at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252)
       at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
       at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
       at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
       at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
       at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
       at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
       at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
       at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:82)
       at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37)
       at com.thoughtworks.xstream.XStream.marshal(XStream.java:1026)
       at com.thoughtworks.xstream.XStream.marshal(XStream.java:1015)
       at com.thoughtworks.xstream.XStream.toXML(XStream.java:988)
       at hudson.XmlFile.write(XmlFile.java:171)
       at hudson.model.Run.save(Run.java:1933)
       at hudson.model.Saveable$save.call(Unknown Source)
       at Script1.run(Script1.groovy:31)
       at groovy.lang.GroovyShell.evaluate(GroovyShell.java:585)
       at groovy.lang.GroovyShell.evaluate(GroovyShell.java:623)
       at groovy.lang.GroovyShell.evaluate(GroovyShell.java:594)
       at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.evaluate(SecureGroovyScript.java:170)
       at hudson.plugins.groovy.SystemGroovy.run(SystemGroovy.java:95)
       at hudson.plugins.groovy.SystemGroovy.perform(SystemGroovy.java:59)
       at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
       at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:736)
       at hudson.model.Build$BuildExecution.build(Build.java:206)
       at hudson.model.Build$BuildExecution.doRun(Build.java:163)
       at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:496)
       at hudson.model.Run.execute(Run.java:1737)
       at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
       at hudson.model.ResourceController.execute(ResourceController.java:97)
       at hudson.model.Executor.run(Executor.java:421)

          [JENKINS-47167] java.lang.NullPointerException in EnvInjectAction.writeReplace

          Oleg Nenashev added a comment -

          I cannot say anything without the plugin version.

          Likely it has been already fixed in recent versions

          Oleg Nenashev added a comment - I cannot say anything without the plugin version. Likely it has been already fixed in recent versions

          updated just now my versions of jenkins and the plugin

          Puneeth Nanjundaswamy added a comment - updated just now my versions of jenkins and the plugin

          Oleg Nenashev added a comment -

          Are there any reproduction steps?
          From the stacktrace I see it happens in System Groovy step within the Freestyle Project job type. I need a sample script at least

          Oleg Nenashev added a comment - Are there any reproduction steps? From the stacktrace I see it happens in System Groovy step within the Freestyle Project job type. I need a sample script at least

          Oleg Nenashev added a comment -

          I have created https://github.com/jenkinsci/envinject-lib/pull/13, but it just improves diagnostics a bit. For me it's still unclear how to reproduce the reported issue

          Oleg Nenashev added a comment - I have created https://github.com/jenkinsci/envinject-lib/pull/13 , but it just improves diagnostics a bit. For me it's still unclear how to reproduce the reported issue

          I think I narrowed it to which job was causing these huge stack traces. It is a script related to JENKINS-19022

           

          The script is below:

           

           
          import hudson.matrix.*
          import hudson.model.*
          hudsonInstance = hudson.model.Hudson.instance
          allItems = hudsonInstance.getAllItems(AbstractProject.class);
          // Iterate over all jobs and find the ones that have a hudson.plugins.git.util.BuildData
          // as an action.
          //
          // We then clean it by removing the useless array action.buildsByBranchName
          //
          for (job in allItems) {
           println("job: " + job.name);
           def counter = 0;
           for (build in job.getBuilds()) {
           // It is possible for a build to have multiple BuildData actions
           // since we can use the Mulitple SCM plugin.
           def gitActions = build.getActions(hudson.plugins.git.util.BuildData.class)
           if (gitActions != null) {
           for (action in gitActions) {
           action.buildsByBranchName = new HashMap<String, Build>();
           hudson.plugins.git.Revision r = action.getLastBuiltRevision();
           if (r != null) {
           for (branch in r.getBranches()) {
           action.buildsByBranchName.put(branch.getName(), action.lastBuild)
           }
           }
           build.actions.remove(action)
           build.actions.add(action)
           build.save();
           counter++;
           }
           }
           if (job instanceof MatrixProject) {
           def runcounter = 0;
           for (run in build.getRuns()) {
           gitActions = run.getActions(hudson.plugins.git.util.BuildData.class)
           if (gitActions != null) {
           for (action in gitActions) {
           action.buildsByBranchName = new HashMap<String, Build>();
           hudson.plugins.git.Revision r = action.getLastBuiltRevision();
           if (r != null) {
           for (branch in r.getBranches()) {
           action.buildsByBranchName.put(branch.getName(), action.lastBuild)
           }
           }
           run.actions.remove(action)
           run.actions.add(action)
           run.save();
           runcounter++;
           }
           }
           }
           if (runcounter > 0) {
           println(" -->> cleaned: " + runcounter + " runs");
           }
           }
           }
           if (counter > 0) {
           println("-- cleaned: " + counter + " builds");
           }
          }
          

           

          Puneeth Nanjundaswamy added a comment - I think I narrowed it to which job was causing these huge stack traces. It is a script related to JENKINS-19022 .    The script is below:     import hudson.matrix.* import hudson.model.* hudsonInstance = hudson.model.Hudson.instance allItems = hudsonInstance.getAllItems(AbstractProject.class); // Iterate over all jobs and find the ones that have a hudson.plugins.git.util.BuildData // as an action. // // We then clean it by removing the useless array action.buildsByBranchName // for (job in allItems) { println( "job: " + job.name); def counter = 0; for (build in job.getBuilds()) { // It is possible for a build to have multiple BuildData actions // since we can use the Mulitple SCM plugin. def gitActions = build.getActions(hudson.plugins.git.util.BuildData.class) if (gitActions != null ) { for (action in gitActions) { action.buildsByBranchName = new HashMap< String , Build>(); hudson.plugins.git.Revision r = action.getLastBuiltRevision(); if (r != null ) { for (branch in r.getBranches()) { action.buildsByBranchName.put(branch.getName(), action.lastBuild) } } build.actions.remove(action) build.actions.add(action) build.save(); counter++; } } if (job instanceof MatrixProject) { def runcounter = 0; for (run in build.getRuns()) { gitActions = run.getActions(hudson.plugins.git.util.BuildData.class) if (gitActions != null ) { for (action in gitActions) { action.buildsByBranchName = new HashMap< String , Build>(); hudson.plugins.git.Revision r = action.getLastBuiltRevision(); if (r != null ) { for (branch in r.getBranches()) { action.buildsByBranchName.put(branch.getName(), action.lastBuild) } } run.actions.remove(action) run.actions.add(action) run.save(); runcounter++; } } } if (runcounter > 0) { println( " -->> cleaned: " + runcounter + " runs" ); } } } if (counter > 0) { println( "-- cleaned: " + counter + " builds" ); } }  

          Oleg Nenashev added a comment -

          Please provide a step-by-step reproduction guide on a clean instance. I understand how it *may* happen, but it requires other bogus system script logic.

          Oleg Nenashev added a comment - Please provide a step-by-step reproduction guide on a clean instance. I understand how it * may * happen, but it requires other bogus system script logic.

          Code changed in jenkins
          User: Oleg Nenashev
          Path:
          pom.xml
          src/main/java/org/jenkinsci/lib/envinject/EnvInjectAction.java
          src/main/java/org/jenkinsci/lib/envinject/EnvInjectLogger.java
          src/main/java/org/jenkinsci/lib/envinject/service/EnvInjectSavable.java
          src/main/java/org/jenkinsci/lib/envinject/service/EnvVarsResolver.java
          http://jenkins-ci.org/commit/envinject-lib/fb78337e7eddf2f0c2626d27c6ba2bbd517849e7
          Log:
          JENKINS-47167 - Handle null build when serializing the object to the disk, patch FindBugs

          FindBugs was using the default “Medium” threshold, and hence it was missing some NPE risks.
          The change improves diagnostics for JENKINS-47167 and cleanups some other code bits

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oleg Nenashev Path: pom.xml src/main/java/org/jenkinsci/lib/envinject/EnvInjectAction.java src/main/java/org/jenkinsci/lib/envinject/EnvInjectLogger.java src/main/java/org/jenkinsci/lib/envinject/service/EnvInjectSavable.java src/main/java/org/jenkinsci/lib/envinject/service/EnvVarsResolver.java http://jenkins-ci.org/commit/envinject-lib/fb78337e7eddf2f0c2626d27c6ba2bbd517849e7 Log: JENKINS-47167 - Handle null build when serializing the object to the disk, patch FindBugs FindBugs was using the default “Medium” threshold, and hence it was missing some NPE risks. The change improves diagnostics for JENKINS-47167 and cleanups some other code bits

          Code changed in jenkins
          User: Oleg Nenashev
          Path:
          pom.xml
          src/main/java/org/jenkinsci/lib/envinject/EnvInjectAction.java
          src/main/java/org/jenkinsci/lib/envinject/EnvInjectLogger.java
          src/main/java/org/jenkinsci/lib/envinject/service/EnvInjectSavable.java
          src/main/java/org/jenkinsci/lib/envinject/service/EnvVarsResolver.java
          http://jenkins-ci.org/commit/envinject-lib/e2d0a75ae2c3b35af50382efd054bdf4d2919333
          Log:
          Merge pull request #13 from oleg-nenashev/bug/JENKINS-47167-diagnostics

          JENKINS-47167 - Handle null build when serializing the object to the disk, patch FindBugs

          Compare: https://github.com/jenkinsci/envinject-lib/compare/781b2577ef38...e2d0a75ae2c3

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oleg Nenashev Path: pom.xml src/main/java/org/jenkinsci/lib/envinject/EnvInjectAction.java src/main/java/org/jenkinsci/lib/envinject/EnvInjectLogger.java src/main/java/org/jenkinsci/lib/envinject/service/EnvInjectSavable.java src/main/java/org/jenkinsci/lib/envinject/service/EnvVarsResolver.java http://jenkins-ci.org/commit/envinject-lib/e2d0a75ae2c3b35af50382efd054bdf4d2919333 Log: Merge pull request #13 from oleg-nenashev/bug/ JENKINS-47167 -diagnostics JENKINS-47167 - Handle null build when serializing the object to the disk, patch FindBugs Compare: https://github.com/jenkinsci/envinject-lib/compare/781b2577ef38...e2d0a75ae2c3

          Code changed in jenkins
          User: Oleg Nenashev
          Path:
          pom.xml
          http://jenkins-ci.org/commit/envinject-api-plugin/3e16ce5885cd361b57a304b6e0a4272717eb0c7f
          Log:
          [JENKINS-47574, JENKINS-47167] - Update to EnvInject Lib 1.28

          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/3e16ce5885cd361b57a304b6e0a4272717eb0c7f Log: [JENKINS-47574, JENKINS-47167] - Update to EnvInject Lib 1.28

          Oleg Nenashev added a comment -

          I have added some diagnostics in EnvInject Lib 1.28 and EnvInject API 1.4

          Oleg Nenashev added a comment - I have added some diagnostics in EnvInject Lib 1.28 and EnvInject API 1.4

          oleg_nenashev sorry for getting back to you a bit late. The script I posted is the one which runs in a freestyle job. I am not seeing these errors now as I disabled the job. I see you released a new version. Will check it out.

          Puneeth Nanjundaswamy added a comment - oleg_nenashev sorry for getting back to you a bit late. The script I posted is the one which runs in a freestyle job. I am not seeing these errors now as I disabled the job. I see you released a new version. Will check it out.

          Thanks a lot for the efforts

          Puneeth Nanjundaswamy added a comment - Thanks a lot for the efforts

          Puneeth Nanjundaswamy added a comment - - edited

          oleg_nenashev I gave your new version a spin, PFA the logs

           

          EnvInject API Plugin
          Stores shared logic for Environment Injection management
          1.4

           

          java.io.InvalidObjectException: Cannot save the environment file. Action org.jenkinsci.plugins.envinject.EnvInjectPluginAction@72fdb3a3 has no associated run instance. Target root dir is unknown
           at org.jenkinsci.lib.envinject.EnvInjectAction.writeReplace(EnvInjectAction.java:145)
           at sun.reflect.GeneratedMethodAccessor297.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
           at java.lang.reflect.Method.invoke(Method.java:498)
           at com.thoughtworks.xstream.converters.reflection.SerializationMethodInvoker.callWriteReplace(SerializationMethodInvoker.java:89)
           at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:141)
           at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
           at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
           at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
           at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88)
           at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:64)
           at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:74)
           at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
           at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
           at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
           at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265)
           at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252)
           at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
           at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
           at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
           at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
           at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
           at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
           at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
           at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265)
           at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252)
           at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
           at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
           at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
           at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
           at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
           at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
           at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
           at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88)
           at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:64)
           at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:74)
           at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
           at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
           at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
           at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265)
           at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252)
           at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
           at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
           at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
           at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
           at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
           at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
           at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
           at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:82)
           at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37)
           at com.thoughtworks.xstream.XStream.marshal(XStream.java:1026)
           at com.thoughtworks.xstream.XStream.marshal(XStream.java:1015)
           at com.thoughtworks.xstream.XStream.toXML(XStream.java:988)
           at hudson.XmlFile.write(XmlFile.java:171)
           at hudson.model.Run.save(Run.java:1933)
           at hudson.model.Saveable$save.call(Unknown Source)
           at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
           at hudson.model.Saveable$save.call(Unknown Source)
           at Script1.run(Script1.groovy:31)
           at groovy.lang.GroovyShell.evaluate(GroovyShell.java:585)
           at groovy.lang.GroovyShell.evaluate(GroovyShell.java:623)
           at groovy.lang.GroovyShell.evaluate(GroovyShell.java:594)
           at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.evaluate(SecureGroovyScript.java:170)
           at hudson.plugins.groovy.SystemGroovy.run(SystemGroovy.java:95)
           at hudson.plugins.groovy.SystemGroovy.perform(SystemGroovy.java:59)
           at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
           at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:736)
           at hudson.model.Build$BuildExecution.build(Build.java:206)
           at hudson.model.Build$BuildExecution.doRun(Build.java:163)
           at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:496)
           at hudson.model.Run.execute(Run.java:1737)
           at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
           at hudson.model.ResourceController.execute(ResourceController.java:97)
           at hudson.model.Executor.run(Executor.java:421)

          Puneeth Nanjundaswamy added a comment - - edited oleg_nenashev I gave your new version a spin, PFA the logs   EnvInject API Plugin Stores shared logic for Environment Injection management 1.4   java.io.InvalidObjectException: Cannot save the environment file. Action org.jenkinsci.plugins.envinject.EnvInjectPluginAction@72fdb3a3 has no associated run instance. Target root dir is unknown at org.jenkinsci.lib.envinject.EnvInjectAction.writeReplace(EnvInjectAction.java:145) at sun.reflect.GeneratedMethodAccessor297.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.thoughtworks.xstream.converters.reflection.SerializationMethodInvoker.callWriteReplace(SerializationMethodInvoker.java:89) at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:141) at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69) at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58) at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43) at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88) at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:64) at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:74) at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69) at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58) at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84) at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265) at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252) at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224) at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138) at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209) at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150) at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69) at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58) at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84) at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265) at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252) at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224) at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138) at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209) at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150) at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69) at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58) at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43) at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88) at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:64) at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:74) at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69) at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58) at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84) at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265) at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252) at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224) at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138) at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209) at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150) at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69) at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58) at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43) at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:82) at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37) at com.thoughtworks.xstream.XStream.marshal(XStream.java:1026) at com.thoughtworks.xstream.XStream.marshal(XStream.java:1015) at com.thoughtworks.xstream.XStream.toXML(XStream.java:988) at hudson.XmlFile.write(XmlFile.java:171) at hudson.model.Run.save(Run.java:1933) at hudson.model.Saveable$save.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at hudson.model.Saveable$save.call(Unknown Source) at Script1.run(Script1.groovy:31) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:585) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:623) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:594) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.evaluate(SecureGroovyScript.java:170) at hudson.plugins.groovy.SystemGroovy.run(SystemGroovy.java:95) at hudson.plugins.groovy.SystemGroovy.perform(SystemGroovy.java:59) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:736) at hudson.model.Build$BuildExecution.build(Build.java:206) at hudson.model.Build$BuildExecution.doRun(Build.java:163) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:496) at hudson.model.Run.execute(Run.java:1737) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:421)

          Oleg Nenashev added a comment -

          puneeth_n as designed, my pull request just added explicit diagnostics for the case. I am still not sure what happens in the case of your particular script. I would recommend debugging your instance in order to check why the improperly initialized EnvInjectAction gets into the list.

          As a workaround you could call "action.onAttached(build)" for each action before saving the run in your script.

          Oleg Nenashev added a comment - puneeth_n as designed, my pull request just added explicit diagnostics for the case. I am still not sure what happens in the case of your particular script. I would recommend debugging your instance in order to check why the improperly initialized EnvInjectAction gets into the list. As a workaround you could call "action.onAttached(build)" for each action before saving the run in your script.

          oleg_nenashev Thanks for the pointers.

           

          I also attach the config.xml if it helps you get more info.

           

          <?xml version='1.0' encoding='UTF-8'?>
          <project>
           <actions/>
           <description></description>
           <keepDependencies>false</keepDependencies>
           <properties>
           <jenkins.model.BuildDiscarderProperty>
           <strategy class="hudson.tasks.LogRotator">
           <daysToKeep>-1</daysToKeep>
           <numToKeep>30</numToKeep>
           <artifactDaysToKeep>-1</artifactDaysToKeep>
           <artifactNumToKeep>-1</artifactNumToKeep>
           </strategy>
           </jenkins.model.BuildDiscarderProperty>
           <hudson.plugins.disk__usage.DiskUsageProperty plugin="disk-usage@0.28"/>
           <com.chikli.hudson.plugin.naginator.NaginatorOptOutProperty plugin="naginator@1.17.2">
           <optOut>false</optOut>
           </com.chikli.hudson.plugin.naginator.NaginatorOptOutProperty>
           <com.synopsys.arc.jenkinsci.plugins.jobrestrictions.jobs.JobRestrictionProperty plugin="job-restrictions@0.6"/>
           <hudson.model.ParametersDefinitionProperty>
           <parameterDefinitions>
           <org.jvnet.jenkins.plugins.nodelabelparameter.NodeParameterDefinition plugin="nodelabelparameter@1.7.2">
           <name>run_on_node</name>
           <description></description>
           <allowedSlaves>
           <string>master</string>
           </allowedSlaves>
           <defaultSlaves>
           <string>master</string>
           </defaultSlaves>
           <triggerIfResult>multiSelectionDisallowed</triggerIfResult>
           <allowMultiNodeSelection>false</allowMultiNodeSelection>
           <triggerConcurrentBuilds>false</triggerConcurrentBuilds>
           <ignoreOfflineNodes>false</ignoreOfflineNodes>
           <nodeEligibility class="org.jvnet.jenkins.plugins.nodelabelparameter.node.AllNodeEligibility"/>
           </org.jvnet.jenkins.plugins.nodelabelparameter.NodeParameterDefinition>
           </parameterDefinitions>
           </hudson.model.ParametersDefinitionProperty>
           </properties>
           <scm class="hudson.scm.NullSCM"/>
           <canRoam>true</canRoam>
           <disabled>true</disabled>
           <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
           <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
           <triggers>
           <hudson.triggers.TimerTrigger>
           <spec>H/30 * * * *</spec>
           </hudson.triggers.TimerTrigger>
           </triggers>
           <concurrentBuild>false</concurrentBuild>
           <builders>
           <hudson.plugins.groovy.SystemGroovy plugin="groovy@2.0">
           <source class="hudson.plugins.groovy.StringSystemScriptSource">
           <script plugin="script-security@1.34">
           <script>import hudson.matrix.*
          import hudson.model.*
           
          hudsonInstance = hudson.model.Hudson.instance
          allItems = hudsonInstance.getAllItems(AbstractProject.class);
           
          // Iterate over all jobs and find the ones that have a hudson.plugins.git.util.BuildData
          // as an action.
          //
          // We then clean it by removing the useless array action.buildsByBranchName
          //
           
          for (job in allItems) {
           println(&quot;job: &quot; + job.name);
           def counter = 0;
           for (build in job.getBuilds()) {
           // It is possible for a build to have multiple BuildData actions
           // since we can use the Mulitple SCM plugin.
           def gitActions = build.getActions(hudson.plugins.git.util.BuildData.class)
           if (gitActions != null) {
           for (action in gitActions) {
           action.buildsByBranchName = new HashMap&lt;String, Build&gt;();
           hudson.plugins.git.Revision r = action.getLastBuiltRevision();
           if (r != null) {
           for (branch in r.getBranches()) {
           action.buildsByBranchName.put(branch.getName(), action.lastBuild)
           }
           }
           build.actions.remove(action)
           build.actions.add(action)
           build.save();
           counter++;
           }
           }
           if (job instanceof MatrixProject) {
           def runcounter = 0;
           for (run in build.getRuns()) {
           gitActions = run.getActions(hudson.plugins.git.util.BuildData.class)
           if (gitActions != null) {
           for (action in gitActions) {
           action.buildsByBranchName = new HashMap&lt;String, Build&gt;();
           hudson.plugins.git.Revision r = action.getLastBuiltRevision();
           if (r != null) {
           for (branch in r.getBranches()) {
           action.buildsByBranchName.put(branch.getName(), action.lastBuild)
           }
           }
           run.actions.remove(action)
           run.actions.add(action)
           run.save();
           runcounter++;
           }
           }
           }
           if (runcounter &gt; 0) {
           println(&quot; --&gt;&gt; cleaned: &quot; + runcounter + &quot; runs&quot;);
           }
           }
           }
           if (counter &gt; 0) {
           println(&quot;-- cleaned: &quot; + counter + &quot; builds&quot;);
           }
          }</script>
           <sandbox>false</sandbox>
           </script>
           </source>
           </hudson.plugins.groovy.SystemGroovy>
           </builders>
           <publishers/>
           <buildWrappers>
           <hudson.plugins.timestamper.TimestamperBuildWrapper plugin="timestamper@1.8.8"/>
           <hudson.plugins.ansicolor.AnsiColorBuildWrapper plugin="ansicolor@0.5.2">
           <colorMapName>gnome-terminal</colorMapName>
           </hudson.plugins.ansicolor.AnsiColorBuildWrapper>
           </buildWrappers>
          </project>

          Puneeth Nanjundaswamy added a comment - oleg_nenashev Thanks for the pointers.   I also attach the config.xml if it helps you get more info.   <?xml version= '1.0' encoding= 'UTF-8' ?> <project> <actions/> <description></description> <keepDependencies> false </keepDependencies> <properties> <jenkins.model.BuildDiscarderProperty> <strategy class= "hudson.tasks.LogRotator" > <daysToKeep>-1</daysToKeep> <numToKeep>30</numToKeep> <artifactDaysToKeep>-1</artifactDaysToKeep> <artifactNumToKeep>-1</artifactNumToKeep> </strategy> </jenkins.model.BuildDiscarderProperty> <hudson.plugins.disk__usage.DiskUsageProperty plugin= "disk-usage@0.28" /> <com.chikli.hudson.plugin.naginator.NaginatorOptOutProperty plugin= "naginator@1.17.2" > <optOut> false </optOut> </com.chikli.hudson.plugin.naginator.NaginatorOptOutProperty> <com.synopsys.arc.jenkinsci.plugins.jobrestrictions.jobs.JobRestrictionProperty plugin= "job-restrictions@0.6" /> <hudson.model.ParametersDefinitionProperty> <parameterDefinitions> <org.jvnet.jenkins.plugins.nodelabelparameter.NodeParameterDefinition plugin= "nodelabelparameter@1.7.2" > <name>run_on_node</name> <description></description> <allowedSlaves> <string>master</string> </allowedSlaves> <defaultSlaves> <string>master</string> </defaultSlaves> <triggerIfResult>multiSelectionDisallowed</triggerIfResult> <allowMultiNodeSelection> false </allowMultiNodeSelection> <triggerConcurrentBuilds> false </triggerConcurrentBuilds> <ignoreOfflineNodes> false </ignoreOfflineNodes> <nodeEligibility class= "org.jvnet.jenkins.plugins.nodelabelparameter.node.AllNodeEligibility" /> </org.jvnet.jenkins.plugins.nodelabelparameter.NodeParameterDefinition> </parameterDefinitions> </hudson.model.ParametersDefinitionProperty> </properties> <scm class= "hudson.scm.NullSCM" /> <canRoam> true </canRoam> <disabled> true </disabled> <blockBuildWhenDownstreamBuilding> false </blockBuildWhenDownstreamBuilding> <blockBuildWhenUpstreamBuilding> false </blockBuildWhenUpstreamBuilding> <triggers> <hudson.triggers.TimerTrigger> <spec>H/30 * * * *</spec> </hudson.triggers.TimerTrigger> </triggers> <concurrentBuild> false </concurrentBuild> <builders> <hudson.plugins.groovy.SystemGroovy plugin= "groovy@2.0" > <source class= "hudson.plugins.groovy.StringSystemScriptSource" > <script plugin= "script-security@1.34" > <script> import hudson.matrix.* import hudson.model.* hudsonInstance = hudson.model.Hudson.instance allItems = hudsonInstance.getAllItems(AbstractProject.class); // Iterate over all jobs and find the ones that have a hudson.plugins.git.util.BuildData // as an action. // // We then clean it by removing the useless array action.buildsByBranchName // for (job in allItems) { println(&quot;job: &quot; + job.name); def counter = 0; for (build in job.getBuilds()) { // It is possible for a build to have multiple BuildData actions // since we can use the Mulitple SCM plugin. def gitActions = build.getActions(hudson.plugins.git.util.BuildData.class) if (gitActions != null ) { for (action in gitActions) { action.buildsByBranchName = new HashMap&lt; String , Build&gt;(); hudson.plugins.git.Revision r = action.getLastBuiltRevision(); if (r != null ) { for (branch in r.getBranches()) { action.buildsByBranchName.put(branch.getName(), action.lastBuild) } } build.actions.remove(action) build.actions.add(action) build.save(); counter++; } } if (job instanceof MatrixProject) { def runcounter = 0; for (run in build.getRuns()) { gitActions = run.getActions(hudson.plugins.git.util.BuildData.class) if (gitActions != null ) { for (action in gitActions) { action.buildsByBranchName = new HashMap&lt; String , Build&gt;(); hudson.plugins.git.Revision r = action.getLastBuiltRevision(); if (r != null ) { for (branch in r.getBranches()) { action.buildsByBranchName.put(branch.getName(), action.lastBuild) } } run.actions.remove(action) run.actions.add(action) run.save(); runcounter++; } } } if (runcounter &gt; 0) { println(&quot; --&gt;&gt; cleaned: &quot; + runcounter + &quot; runs&quot;); } } } if (counter &gt; 0) { println(&quot;-- cleaned: &quot; + counter + &quot; builds&quot;); } }</script> <sandbox> false </sandbox> </script> </source> </hudson.plugins.groovy.SystemGroovy> </builders> <publishers/> <buildWrappers> <hudson.plugins.timestamper.TimestamperBuildWrapper plugin= "timestamper@1.8.8" /> <hudson.plugins.ansicolor.AnsiColorBuildWrapper plugin= "ansicolor@0.5.2" > <colorMapName>gnome-terminal</colorMapName> </hudson.plugins.ansicolor.AnsiColorBuildWrapper> </buildWrappers> </project>

          oleg_nenashev I narrowed the troubling job that caused these errors. I have 3 MultiJobProject projects that throw these errors.

          Puneeth Nanjundaswamy added a comment - oleg_nenashev I narrowed the troubling job that caused these errors. I have 3 MultiJobProject projects that throw these errors.

          Oleg Nenashev added a comment -

          Did the workaround above help you?

          Oleg Nenashev added a comment - Did the workaround above help you?

          Oleg Nenashev added a comment -

          Nothing left to do here about EnvInject IMO

          Oleg Nenashev added a comment - Nothing left to do here about EnvInject IMO

          Closing issue as part of tikal-multijob-plugin issues cleanup.
          If still relevant, please open a matching issue in https://github.com/jenkinsci/tikal-multijob-plugin/issues (you can refer to this issue in its description)

          Yoram Michaeli added a comment - Closing issue as part of tikal-multijob-plugin issues cleanup. If still relevant, please open a matching issue in https://github.com/jenkinsci/tikal-multijob-plugin/issues (you can refer to this issue in its description)

            Unassigned Unassigned
            puneeth_n Puneeth Nanjundaswamy
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: