Groovy PostBuild script now failing

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      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:

      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
      

      The script looks like this:

      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}"
      
      

      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.

            Assignee:
            Unassigned
            Reporter:
            Find and Watch
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: