Just don't throw error, especially RuntimeException.
On Thursday, January 29, 2015 at 3:04:52 AM UTC+3, MCSF wrote:
>
> Hello,
> I want to be able to exit the Groovy postbuild step gracefully if the
> build status was ABORTED.
> Here is what I have now:
>
> def buildstatus = manager.build.getResult()
> if ("$buildstatus".equalsIgnoreCase( "ABORTED" ) )
> {
> manager.addShortText("Build $buildstatus; exiting Groovy", "red",
> "white", "0px", "white")
> throw new RuntimeException("buildstatus is $buildstatus ")
> }
> // do normal stuff if build was not aborted
>
>
> The above code works, but it spews a bunch of Groovy errors onto the build
> page:
>
> *Groovy script failed:*
>
> java.lang.RuntimeException: buildstatus is ABORTED
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
> at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
> at
> org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
> at
> org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:71)
> at
> org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:81)
> at
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:54)
> at
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
> at
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)
> at Script1.run(Script1.groovy:5)
> 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:804)
> at
> hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:776)
> at hudson.model.Build$BuildExecution.post2(Build.java:183)
> at
> hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:725)
> at hudson.model.Run.execute(Run.java:1709)
> at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
> at hudson.model.ResourceController.execute(ResourceController.java:88)
> at hudson.model.Executor.run(Executor.java:231)
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/a91ff9cf-7816-432b-9dd8-cb3631b60f07%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.