java.lang.IllegalStateException: cannot change build result while in COMPLETED

Jenkins JIRA | Find and Watch | 3 years ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    Hi we upgraded our Jenkins version today from 1.574 to the latest 1.590. We had a job which ran a groovy postbuild script that would mark a trigger job as failed if any of the downstream jobs from the trigger failed. This worked on the previous version we were using, but now we are getting: {code} ERROR: Failed to evaluate groovy script. java.lang.IllegalStateException: cannot change build result while in COMPLETED at hudson.model.Run.setResult(Run.java:458) at hudson.model.Run$setResult.call(Unknown Source) 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:9) 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:312) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:770) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:734) at hudson.model.Build$BuildExecution.post2(Build.java:183) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:683) at hudson.model.Run.execute(Run.java:1784) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:89) at hudson.model.Executor.run(Executor.java:240) Build step 'Groovy Postbuild' changed build result to FAILURE Build step 'Groovy Postbuild' marked build as failure {code} The script looks like this: {code} import jenkins.model.Jenkins import hudson.model.* def fawTriggerTest = Jenkins.instance.getItem('faw-trigger-tests') def buildNumber = manager.build.buildVariables.VERSION_NUMBER as int def build = fawTriggerTest.getBuildByNumber(buildNumber) manager.listener.logger.println "faw-trigger-test $buildNumber currently is ${build.result}" manager.listener.logger.println "About to mark $buildNumber as failed" build.setResult(Result.FAILURE) manager.listener.logger.println "faw-trigger-test $buildNumber is now ${build.result}" {code} We've looked at the API and see that we are not allowed to change status of a COMPLETED job. Is this a new update seeing as this worked previously? If we are no longer allowed to do this, is there a way we can mark another job as a failure once it is in a completed state. P.S. We havent updated the Groovy PostBuild plugin due to a warning on the updates page which is quite off putting.

    Jenkins JIRA | 3 years ago | Find and Watch
    java.lang.IllegalStateException: cannot change build result while in COMPLETED
  2. 0

    Hi we upgraded our Jenkins version today from 1.574 to the latest 1.590. We had a job which ran a groovy postbuild script that would mark a trigger job as failed if any of the downstream jobs from the trigger failed. This worked on the previous version we were using, but now we are getting: {code} ERROR: Failed to evaluate groovy script. java.lang.IllegalStateException: cannot change build result while in COMPLETED at hudson.model.Run.setResult(Run.java:458) at hudson.model.Run$setResult.call(Unknown Source) 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:9) 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:312) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:770) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:734) at hudson.model.Build$BuildExecution.post2(Build.java:183) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:683) at hudson.model.Run.execute(Run.java:1784) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:89) at hudson.model.Executor.run(Executor.java:240) Build step 'Groovy Postbuild' changed build result to FAILURE Build step 'Groovy Postbuild' marked build as failure {code} The script looks like this: {code} import jenkins.model.Jenkins import hudson.model.* def fawTriggerTest = Jenkins.instance.getItem('faw-trigger-tests') def buildNumber = manager.build.buildVariables.VERSION_NUMBER as int def build = fawTriggerTest.getBuildByNumber(buildNumber) manager.listener.logger.println "faw-trigger-test $buildNumber currently is ${build.result}" manager.listener.logger.println "About to mark $buildNumber as failed" build.setResult(Result.FAILURE) manager.listener.logger.println "faw-trigger-test $buildNumber is now ${build.result}" {code} We've looked at the API and see that we are not allowed to change status of a COMPLETED job. Is this a new update seeing as this worked previously? If we are no longer allowed to do this, is there a way we can mark another job as a failure once it is in a completed state. P.S. We havent updated the Groovy PostBuild plugin due to a warning on the updates page which is quite off putting.

    Jenkins JIRA | 3 years ago | Find and Watch
    java.lang.IllegalStateException: cannot change build result while in COMPLETED

    1 unregistered visitors

    Root Cause Analysis

    1. java.lang.IllegalStateException

      cannot change build result while in COMPLETED

      at hudson.model.Run.setResult()
    2. Hudson
      Run$setResult.call
      1. hudson.model.Run.setResult(Run.java:458)
      2. hudson.model.Run$setResult.call(Unknown Source)
      2 frames
    3. Groovy
      AbstractCallSite.call
      1. org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
      2. org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
      3. org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
      3 frames
    4. Unknown
      Script1.run
      1. Script1.run(Script1.groovy:9)
      1 frame
    5. 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
    6. org.jvnet.hudson
      GroovyPostbuildRecorder.perform
      1. org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder.perform(GroovyPostbuildRecorder.java:312)
      1 frame
    7. Hudson
      Executor.run
      1. hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
      2. hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:770)
      3. hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:734)
      4. hudson.model.Build$BuildExecution.post2(Build.java:183)
      5. hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:683)
      6. hudson.model.Run.execute(Run.java:1784)
      7. hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      8. hudson.model.ResourceController.execute(ResourceController.java:89)
      9. hudson.model.Executor.run(Executor.java:240)
      9 frames