1

I have a pipeline where all the stages are test stages (no build stage, given that it is matlab code).

Most of the times when a stage fails, it is marked in red (failure) (e.g. in the blueocean pipeline graph), but sometimes all the stages are marked yellow (unstable), making it difficult to identify in what stage the things failed.

My question is, how does Jenkins determine if a stage is a build step (for which the result will be marked failure) or a test step (for which the result will be marked unstable)?

My goal is to always mark the stages as failed, not unstable, if they fail.

My stages are named as following:

stage('Check modified files')
  stage('Check examples (modified files)')
  stage('Unit testing (modified files)')
stage('Unit testing (dependent units/modules)')
Simone Gaiarin
  • 340
  • 2
  • 15
  • Possible duplicate of [Failure / Unstable via Script Return Code](https://stackoverflow.com/questions/25442343/failure-unstable-via-script-return-code) – Mostafa Hussein Feb 13 '19 at 13:49
  • The results of the job can be `failure`, `successful` or `unstable` , I guess it depends on the given steps / plugins what they will return on "fail" , try on your own manually force to setup status of pipeline, follow https://support.cloudbees.com/hc/en-us/articles/218554077-How-to-set-current-build-result-in-Pipeline- , `UNSTABLE` should work as well, briefly a little more explanation [Jenkins Pipeline Fails if Step is Unstable](https://stackoverflow.com/questions/38713865/jenkins-pipeline-fails-if-step-is-unstable) – xxxvodnikxxx Feb 13 '19 at 14:33

1 Answers1

1

The documentation says

A build is broken if it failed during building. That is, it is not successful

and

A build is unstable if it was built successfully and one or more publishers report it unstable. For example, if the JUnit publisher is configured and a test fails then the build will be marked unstable.

To make Jenkins build failing on a test failure, you should setup Maven Surefire Plugin accordingly. The answer may be helpful https://stackoverflow.com/a/28684048/2443502. You can also try Fail The Build Jenkins plugin.

Marcin Kłopotek
  • 5,271
  • 4
  • 31
  • 51
  • 1
    Thanks for the answer. Now I got it, basically the UNSTABLE status is only determined by the results of the JUnit test in my case. Though I had configured the script that run the tests to exit with exit code 1 if any of the tests fails in order to not execute the next pipeline stages. I could have managed this in the Jenkins pipeline, instead that in my script with the exit code. – Simone Gaiarin Feb 14 '19 at 08:28