java.lang.NullPointerException: Cannot invoke method isBetterThan() on null object

Jenkins JIRA | Christoph Moser | 4 years ago
  1. 0

    We use the Groovy-Postbuild-Plugin to set successful Upstream-Builds to failed, when a downstream-Build failes. The upstream-Build saves several Artefacts and creates Fingerprints from these. Some times the Groovy-Postbuild-Plugin works with the code below for ten or more builds, afterwards we get the below mentioned NullPointerException several times without changing anything in the configuration. ________________________________________________________ Groovy-Code: upstreamBuilds = manager.build.getUpstreamBuilds(); upstreamJob = upstreamBuilds.keySet().iterator().next(); lastUpstreamBuild = upstreamJob.getLastBuild(); if(lastUpstreamBuild.getResult().isBetterThan(manager.build.result)) { lastUpstreamBuild.setResult(manager.build.result); } ________________________________________________________ Exception: Groovy script failed: java.lang.NullPointerException: Cannot invoke method isBetterThan() on null object at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42) at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:32) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) at Script1.run(Script1.groovy:23) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:580) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:618) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:589) at org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder.perform(GroovyPostbuildRecorder.java:273) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:717) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:692) at hudson.model.Build$BuildExecution.post2(Build.java:183) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:639) at hudson.model.Run.execute(Run.java:1485) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:239)

    Jenkins JIRA | 4 years ago | Christoph Moser
    java.lang.NullPointerException: Cannot invoke method isBetterThan() on null object
  2. 0

    We use the Groovy-Postbuild-Plugin to set successful Upstream-Builds to failed, when a downstream-Build failes. The upstream-Build saves several Artefacts and creates Fingerprints from these. Some times the Groovy-Postbuild-Plugin works with the code below for ten or more builds, afterwards we get the below mentioned NullPointerException several times without changing anything in the configuration. ________________________________________________________ Groovy-Code: upstreamBuilds = manager.build.getUpstreamBuilds(); upstreamJob = upstreamBuilds.keySet().iterator().next(); lastUpstreamBuild = upstreamJob.getLastBuild(); if(lastUpstreamBuild.getResult().isBetterThan(manager.build.result)) { lastUpstreamBuild.setResult(manager.build.result); } ________________________________________________________ Exception: Groovy script failed: java.lang.NullPointerException: Cannot invoke method isBetterThan() on null object at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42) at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:32) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) at Script1.run(Script1.groovy:23) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:580) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:618) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:589) at org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder.perform(GroovyPostbuildRecorder.java:273) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:717) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:692) at hudson.model.Build$BuildExecution.post2(Build.java:183) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:639) at hudson.model.Run.execute(Run.java:1485) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:239)

    Jenkins JIRA | 4 years ago | Christoph Moser
    java.lang.NullPointerException: Cannot invoke method isBetterThan() on null object
  3. 0

    Jenkins Active Choices Plugin, Dynamically populate dropdown with Properties file

    Stack Overflow | 1 year ago | Codemiester
    java.lang.NullPointerException: Cannot invoke method split() on null object
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    ERROR: Processing failed due to a bug in the code.

    Google Groups | 4 years ago | Ahmet Maruf Aytekin
    java.lang.NullPointerException: Cannot invoke method getModuleRecords() on null object
  6. 0

    How do you configure the Jenkins "Create Job Advanced" plugin via groovy?

    Stack Overflow | 1 year ago | user3358549
    java.lang.NullPointerException: Cannot invoke method configure() on null object

  1. mortalman7 2 times, last 5 months ago
  2. rlovtangen 1 times, last 6 months ago
22 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.NullPointerException

    Cannot invoke method isBetterThan() on null object

    at org.codehaus.groovy.runtime.NullObject.invokeMethod()
  2. Groovy
    AbstractCallSite.call
    1. org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77)
    2. org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
    3. org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
    4. org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:32)
    5. org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
    6. org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    7. org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    7 frames
  3. Unknown
    Script1.run
    1. Script1.run(Script1.groovy:23)
    1 frame
  4. Groovy
    GroovyShell.evaluate
    1. groovy.lang.GroovyShell.evaluate(GroovyShell.java:580)
    2. groovy.lang.GroovyShell.evaluate(GroovyShell.java:618)
    3. groovy.lang.GroovyShell.evaluate(GroovyShell.java:589)
    3 frames
  5. org.jvnet.hudson
    GroovyPostbuildRecorder.perform
    1. org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder.perform(GroovyPostbuildRecorder.java:273)
    1 frame
  6. Hudson
    Executor.run
    1. hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
    2. hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:717)
    3. hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:692)
    4. hudson.model.Build$BuildExecution.post2(Build.java:183)
    5. hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:639)
    6. hudson.model.Run.execute(Run.java:1485)
    7. hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    8. hudson.model.ResourceController.execute(ResourceController.java:88)
    9. hudson.model.Executor.run(Executor.java:239)
    9 frames