Continue Jenkins job after failed stage while marking stage as failed
Asked Answered
S

4

1

I currently have separate perf tests running as 4 jenkins stages. Currently if a perf test fails the entire pipeline fails. I can mitigate this by wrapping in a try catch which will let me continue, but will mark the stage as a success when it has actually failed. I'd like to get a red failure box for the stage that has failed, and allow the other stages to run. I'm not worried if Jenkins marks the entire job as a failure, so long as the stage that failed is highlighted and doesn't prevent other stages from running.

Saree answered 20/7, 2017 at 18:58 Comment(0)
P
1

Have a look here Show a Jenkins pipeline stage as failed without failing the whole job

Note that you have a choice whether to mark the whole job as failed or not, but most importantly all stages are done regardless while marking those that failed.

I think this is a duplicate question, but I can't link the questions.

Phenylamine answered 23/2, 2018 at 9:39 Comment(0)
D
0

This is not possible. Stages can only run if preceding stages pass.

One thing you could do that would have a similar effect is to run four jobs in parallel in the same stage. I don't know if you currently use the blue ocean UI, but it shows each job in a stage in a separate little circle, and if one fails, it is very obvious which one failed (very much like the classic pipeline UI where you can tell exactly which stage failed).
There's some pictures of what I'm talking about at https://jenkins.io/blog/2016/05/26/introducing-blue-ocean/, including this.

Dalt answered 21/7, 2017 at 0:55 Comment(0)
H
0

To ignore test phase failure, we can add below parameter under maven goals in jenkins

clean install -PDEV Dmaven.test.failure.ignore=true
Henna answered 1/11, 2018 at 4:36 Comment(0)
S
0

Answer to my own question:
Wrap the stage in question in a try/catch or catchError

catchError{
  stage("stage"){
    // command
  }
}

The pipeline will continue but the stage will be marked as failure/red in the GUI and the rest of the job will continue.

Saree answered 9/11, 2020 at 15:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.