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

Groovy PostBuild script now failing

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Blocker
    • Resolution: Won't Fix
    • None
    • Jenkins ver 1.590
      Groovy Postbuild 1.10

    Description

      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.

      Attachments

        Activity

          Just a comment, we've rolled back to our old version and it's working again. We want to be able to upgrade to the latest Jenkins, so any help with this would be appreciated.

          findandwatch Find and Watch added a comment - Just a comment, we've rolled back to our old version and it's working again. We want to be able to upgrade to the latest Jenkins, so any help with this would be appreciated.
          danielbeck Daniel Beck added a comment -

          This change in core is deliberate and there's nothing Groovy Postbuild can do about it. The change in question upgraded an assertion error (disabled by default) to an exception, which means that now, Jenkins means it.

          danielbeck Daniel Beck added a comment - This change in core is deliberate and there's nothing Groovy Postbuild can do about it. The change in question upgraded an assertion error (disabled by default) to an exception, which means that now, Jenkins means it.

          People

            Unassigned Unassigned
            findandwatch Find and Watch
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: