What's the api to fail a build

25 views
Skip to first unread message

Michael Fowler

unread,
Aug 13, 2018, 7:26:26 PM8/13/18
to Jenkins Developers
Hi All,
 I made the change shown below to remove an ugly stack trace from the log. However, now the build status doesn't get set to failure. Whats the best way to fail the build without throwing AbbortException?

abort exception.png



Daniel Beck

unread,
Aug 13, 2018, 9:00:33 PM8/13/18
to jenkin...@googlegroups.com

> On 14. Aug 2018, at 01:26, Michael Fowler <michael...@gmail.com> wrote:
>
> I made the change shown below to remove an ugly stack trace from the log. However, now the build status doesn't get set to failure. Whats the best way to fail the build without throwing AbbortException?
>

This should work, unless you're in a Pipeline and the exception gets caught. Could that be the problem?

Michael Fowler

unread,
Aug 13, 2018, 11:35:02 PM8/13/18
to jenkin...@googlegroups.com
Hey Dan,
 It's in a pipeline. No exception was thrown, that line was removed. The pipeline stopped on the next line. I checked the source for that plugin, it throws an exception. There's got to be a better way than having a stack trace in the build log.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/swm_sgA1eGg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/129954F1-8976-4BC2-B02E-40E80EB9AA70%40beckweb.net.
For more options, visit https://groups.google.com/d/optout.

Daniel Beck

unread,
Aug 14, 2018, 2:12:33 AM8/14/18
to jenkin...@googlegroups.com

> On 14. Aug 2018, at 05:34, Michael Fowler <michael...@gmail.com> wrote:
>
> It's in a pipeline. No exception was thrown, that line was removed. The pipeline stopped on the next line. I checked the source for that plugin, it throws an exception. There's got to be a better way than having a stack trace in the build log.

Oops -- read the diff the wrong way, since throwing AbortException is the recommended way to do something like this. Could you provide more context about the stack trace?


Michael Fowler

unread,
Aug 14, 2018, 11:43:30 AM8/14/18
to Jenkins Developers
Here's what was in the build log when the exception was thrown:
FATAL: execution failed
hudson.AbortException: Exited with code: 1
	at org.jenkinsci.plugins.windows_exe_runner.ExeBuilder.exec(ExeBuilder.java:234)
	at org.jenkinsci.plugins.windows_exe_runner.ExeBuilder.perform(ExeBuilder.java:134)
	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:80)
	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:67)
	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution$1$1.call(SynchronousNonBlockingStepExecution.java:50)
	at hudson.security.ACL.impersonate(ACL.java:260)
	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution$1.run(SynchronousNonBlockingStepExecution.java:47)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

Jesse Glick

unread,
Aug 14, 2018, 1:25:24 PM8/14/18
to Jenkins Dev
On Tue, Aug 14, 2018 at 11:43 AM Michael Fowler
<michael...@gmail.com> wrote:
> FATAL: execution failed

I do not recognize where this message line is coming from.

Throwing an `AbortException` is the correct response to a foreseeable,
user-level error condition. It should not be displayed as a stack
trace.

From a full-text search of @jenkinsci I would look first at

https://github.com/jenkinsci/windows-exe-runner-plugin/blob/813facfd3b4482ddd7492e0c904c957e18a45257/src/main/java/org/jenkinsci/plugins/windows_exe_runner/ExeBuilder.java#L244

which appears wrong. All the `catch` blocks (lines 242, 246, and 254)
should be deleted.

If you are working on some other code and still having problems,
narrow down your issue to a minimal reproducible test case (e.g., a
small plugin adding a Pipeline step) and file a bug report.
Reply all
Reply to author
Forward
0 new messages