terminate pipeline parallal on first failure

149 views
Skip to first unread message

Åsmund Østvold

unread,
Sep 20, 2016, 4:43:38 PM9/20/16
to jenkins...@googlegroups.com
hi All,

Do anybody have an example or a pointer to how one could terminate a parallel pipeline section on first failure?

The use case is that I have 14 tests in a checkin regression pipeline. Some tests take 2 min some take 40 min. To speed up feedback to the users we want to give feed back ASAP if a test did fail.

My test pipeline is:

    stage('tests') {
        parallel 'longTests': {
            build job: 'testjob1', quietPeriod: 0
        }, 'shortTests':{
            // this will fail 1 sec
            build job: 'testjob2', quietPeriod: 0
        }
    }

My current "pipeline" (Build-flow) is able to do this with a ugly hack:

import static hudson.model.Result.FAILURE
import groovy.time.*

parallel (
  { b = build("testjob1")
    if (b.getResult().toString() != "SUCCESS") {
upstream.getExecutor().interrupt(FAILURE)
       }
  },
  { b = build("testjob2"])
    if (b.getResult().toString() != "SUCCESS") {
upstream.getExecutor().interrupt(FAILURE)
       }
  }
)

Regard,
Asmund

Baptiste Mathus

unread,
Sep 20, 2016, 4:47:53 PM9/20/16
to jenkins...@googlegroups.com
Hi,

 stage('tests') {
        parallel 'longTests': {
            build job: 'testjob1', quietPeriod: 0
        }, 'shortTests':{
            // this will fail 1 sec
            build job: 'testjob2', quietPeriod: 0
        }, failFast: true       

    }

Cheers

--
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 jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CA%2BzfM3Bq0x7djYpWaXfvSbHrFf2DuGJeZ8fEsVskT%3DDfTeKq2w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Åsmund Østvold

unread,
Sep 20, 2016, 4:57:43 PM9/20/16
to jenkins...@googlegroups.com
Thank you Baptiste!

Tested and it worked. You owe you a beer! 

I am new to pipeline programming. I worked several hours today on this and other pipeline related work. Could you please point me to the documentation of this syntax? I must have been looking in the wrong location. 

Cheers



Cuong Tran

unread,
Sep 20, 2016, 11:42:40 PM9/20/16
to Jenkins Users
The reference link is right on any pipeline job.  You should see a "Pipeline Syntax" link, click on that will give a list of known steps, the click on the question icon will give you an example.

To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.

--
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 jenkinsci-use...@googlegroups.com.

Michael Neale

unread,
Sep 21, 2016, 2:34:03 AM9/21/16
to Jenkins Users
There is also: https://jenkins.io/doc/pipeline/

but generally for the steps - if you open a job to edit, you should see either near the pipeline text area or on the left a "Pipeline Syntax" link you can open in a new tab. It gives you a choice of steps that will build the syntax out for you as things you can copy and paste.

Åsmund Østvold

unread,
Sep 21, 2016, 4:38:41 PM9/21/16
to jenkins...@googlegroups.com

Thank you Cuong and Michael,

IIRC my Jenkins install do not give me the choice for "failFast: true" that I was searching for. Will check tomorrow. But if somebody has a link to the "full" syntax I would love to have it.

Asmund


To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/56293faf-3380-4601-ab74-ccf8710f4c56%40googlegroups.com.

Baptiste Mathus

unread,
Sep 21, 2016, 4:50:02 PM9/21/16
to jenkins...@googlegroups.com
o/ Didn't check, but this should be in the "Snippet Generator".



Michael Neale

unread,
Sep 21, 2016, 7:36:30 PM9/21/16
to Jenkins Users, m...@batmat.net
If it isn't, please do raise a ticket as it is an important feature of parallel for people to know about. 

--
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 jenkinsci-use...@googlegroups.com.

Åsmund Østvold

unread,
Sep 22, 2016, 2:41:35 PM9/22/16
to jenkins...@googlegroups.com

It was hidden under the document question mark.

Should I make a issue?

Asmund


To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/3f573e87-2608-4c74-bf8b-932900b31597%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages