Builds are tagged unstable even when they are successful

JavaMaven 2MavenMaven 3Jenkins

Java Problem Overview


I am running Jenkins version 1.411 and use Maven for building.

Even though the application builds successfully, Jenkins treats it as an unstable build. I have disabled all tests to isolate the problem.

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 45.389s
[INFO] Finished at: Wed May 11 12:16:57 EST 2011
[INFO] [DocLinks] Skip document Adaptiv generated site ... (No such directory: site)
Final Memory: 27M/543M
[INFO] ------------------------------------------------------------------------
channel stopped
Archiving artifacts
Email was triggered for: Unstable
Sending email for trigger: Unstable
An attempt to send an e-mail to empty list of recipients, ignored.
Finished: SUCCESS

Java Solutions


Solution 1 - Java

It's some time ago that I used hudson/jenkins but you should have a look at the Jenkins Glossary

Unstable build: 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.

Publisher: A publisher is part of the build process other than compilation, for example JUnit test runs. A publisher may report stable or unstable result depending on the result of its processing. For example, if a JUnit test fails, then the whole JUnit publisher may report unstable.

So I suppose you have some other build parts (apart from JUnit) that report an unstable result. Have a look at the whole build process log.

Solution 2 - Java

If you have unit tests, make sure that they run when executing your build.

In my case, the unit tests are not run and Jenkins tagged the build as Unstable. When checking the console output, I found that 0 unit tests were running :

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

The fix for me is will not help resolve this topic but no harm to mention it:

I was Spring boot 2.2 and when I upgraded to v2.5, JUnit 5’s Vintage Engine was removed from spring-boot-starter-test, so I needed to add it to execute tests using JUnit 4.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCroydon DiasView Question on Stackoverflow
Solution 1 - JavaFrVaBeView Answer on Stackoverflow
Solution 2 - JavaYellowStrawHatterView Answer on Stackoverflow