Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Jenkins pipeline parallel stages, how to promptly kill other stages if one fail?

If the job failed, I don't have to wait everybody to finish. Is it possible to abort the parallel stages that are still running. They must display as "aborted", not with a red cross icon, since the failed one must be highlighted.

like image 260
neves Avatar asked Feb 14 '19 20:02

neves


People also ask

What is fail fast in Jenkins pipeline?

Solution: Use failFast flag on Jenkins pipeline. From Documentation: You can force your parallel stages to all be aborted when one of them fails, by adding failFast true to the stage containing the parallel.

What is parallel execution in Jenkins?

This plugin adds a tool that lets you easily execute tests in parallel. This is achieved by having Jenkins look at the test execution time of the last run, split tests into multiple units of roughly equal size, then execute them in parallel.


1 Answers

Add parallelsAlwaysFailFast to your options{} and the whole pipeline will stop if any (parallelized) stage fails.

parallelsAlwaysFailFast Set failfast true for all subsequent parallel stages in the pipeline.

For example: options { parallelsAlwaysFailFast() }

Example:

pipeline {
  agent none
  options {
    parallelsAlwaysFailFast()
  }
  stages {
     ...
  }
}

The option highlights the failed stage. Unfortunately the other stages are not displayed as aborted they just get the usual (not highlighted) red color.

like image 151
Michael Kemmerzell Avatar answered Oct 21 '22 00:10

Michael Kemmerzell