How to stop the current pipeline step?

32 views
Skip to first unread message

Ivo Bellin Salarin

unread,
Sep 4, 2017, 12:47:55 PM9/4/17
to jenkin...@googlegroups.com
Hi all,

I am implementing the pipeline functionality for an existing plugin. Currently, on an eventual error the plugin sets the build status to FAILURE: the build continues executing all the build steps after the current one, and its status is set to failure, as expected.

But I would like the build to stop right after this step execution, skipping all the following steps . On some SO posts I have found that the ABORTED step should be preferred to FAILURE to obtain this behavior. Is this right? I am persuaded that the official Javadoc documentation is unclear. Has somebody a better explanation/documentation about the build Result(s) codes?

Many thanks in advance,
Ivo

Stephen Connolly

unread,
Sep 4, 2017, 2:29:23 PM9/4/17
to jenkin...@googlegroups.com
On Mon 4 Sep 2017 at 17:47, Ivo Bellin Salarin <ivo.bell...@gmail.com> wrote:
Hi all,

I am implementing the pipeline functionality for an existing plugin. Currently, on an eventual error the plugin sets the build status to FAILURE: the build continues executing all the build steps after the current one, and its status is set to failure, as expected

Are you throwing an exception after setting the build result?

Iirc you should be throwing something if you want the execution to "stop"

(Though finally-type behaviour should continue execution)
.

But I would like the build to stop right after this step execution, skipping all the following steps . On some SO posts I have found that the ABORTED step should be preferred to FAILURE to obtain this behavior. Is this right? I am persuaded that the official Javadoc documentation is unclear. Has somebody a better explanation/documentation about the build Result(s) codes?

Many thanks in advance,
Ivo

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAPc4eF8Kif5jUUu9hf7h%2Bo%3DzMuqPY8cXxzacRwzQcrG7hunkNg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
Sent from my phone

Ivo Bellin Salarin

unread,
Sep 4, 2017, 3:42:21 PM9/4/17
to jenkin...@googlegroups.com

No, I wasn't throwing anything, since in the past the perform(Abstract build, ...) was returning a Boolean, and AFAIk a False was sufficient to stop the execution...

Should the thrown exception belong to a definite set, or inherit from a specific base type?


Stephen Connolly

unread,
Sep 4, 2017, 3:56:01 PM9/4/17
to jenkin...@googlegroups.com

On 4 September 2017 at 12:42, Ivo Bellin Salarin <ivo.bell...@gmail.com> wrote:

No, I wasn't throwing anything, since in the past the perform(Abstract build, ...) was returning a Boolean, and AFAIk a False was sufficient to stop the execution...

Should the thrown exception belong to a definite set, or inherit from a specific base type?


On lun. 4 sept. 2017 à 20:29 Stephen Connolly <stephen.alan.connolly@gmail.com> wrote:
On Mon 4 Sep 2017 at 17:47, Ivo Bellin Salarin <ivo.bell...@gmail.com> wrote:
Hi all,

I am implementing the pipeline functionality for an existing plugin. Currently, on an eventual error the plugin sets the build status to FAILURE: the build continues executing all the build steps after the current one, and its status is set to failure, as expected

Are you throwing an exception after setting the build result?

Iirc you should be throwing something if you want the execution to "stop"

(Though finally-type behaviour should continue execution)
.

But I would like the build to stop right after this step execution, skipping all the following steps . On some SO posts I have found that the ABORTED step should be preferred to FAILURE to obtain this behavior. Is this right? I am persuaded that the official Javadoc documentation is unclear. Has somebody a better explanation/documentation about the build Result(s) codes?

Many thanks in advance,
Ivo

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.
--
Sent from my phone

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAPc4eF9KnxMLfEafznXvm3_DqgKJBrmxP6jHyJg2akj9uPKuLg%40mail.gmail.com.

Jesse Glick

unread,
Sep 5, 2017, 6:03:53 PM9/5/17
to Jenkins Dev
Throw `AbortException`. Do _not_ attempt to set the build status yourself.

Ivo Bellin Salarin

unread,
Sep 7, 2017, 9:02:24 AM9/7/17
to Jenkins Dev
@Jesse: what's the preferred way to set the build result to unstable?

Le mer. 6 sept. 2017 à 00:03, Jesse Glick <jgl...@cloudbees.com> a écrit :
Throw `AbortException`. Do _not_ attempt to set the build status yourself.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr249nUA1vquuFLXTFfdW3h0a7jWgeysUFzTu5efH%3DxnDA%40mail.gmail.com.

Jesse Glick

unread,
Sep 7, 2017, 11:06:39 AM9/7/17
to Jenkins Dev
On Thu, Sep 7, 2017 at 9:02 AM, Ivo Bellin Salarin
<ivo.bell...@gmail.com> wrote:
> @Jesse: what's the preferred way to set the build result to unstable?

`setResult(UNSTABLE)`. But if your step “fails”, just throw
`AbortException` and let the caller decide what to do.
Reply all
Reply to author
Forward
0 new messages