I understood from various emails, issues, discussions and source code that it is a wanted behavior to set a build UNSTABLE when (surefire or failsafe) tests fail. That is consistent with https://wiki.jenkins-ci.org/display/JENKINS/Terminology
However, the current behavior is error-prone and inconsistent with a command line or Freestyle job Maven execution.
I guess that if the UNSTABLE status was that much important, it would have been implemented on Freestyle jobs too. Especially since Freestyle are so often recommended rather than the useful Maven job.
Problem
First main issue is the build continuation.
Second issue is the behavior difference between Maven and Freestyle jobs.
Freestyle job
The result is the same as an execution from command line:
- Maven execution is interrupted
- Maven build is FAILURE
- Jenkins build is FAILURE
Reproducing the Maven job behavior is partially possible with -Dmaven.test.failure.ignore=true option and the use of 'Publish JUnit test result report' post build step (to change the build result from SUCCESS to UNSTABLE).
Maven job
The result is similar to using the -Dmaven.test.failure.ignore=true option:
- the Maven execution is not interrupted
- Maven build is SUCCESS
- Jenkins build is UNSTABLE
Responsible code is there: https://github.com/jenkinsci/maven-plugin/blob/maven-plugin-2.6/src/main/java/hudson/maven/reporters/SurefireArchiver.java#L88
The main issue is the build continuation, which will for instance install the artifacts:
ḧ3. Solutions
Add an option for ignoring or not the test failures during the build.
An option would highlight that behavior and allow to easily switch from a testFailureIgnore mode to a standard mode.
Rather use -fae Maven 3 option, or improve current implementation not to use the testFailureIgnore property hack
That would not be the exact equivalent to the current implementation but would still allow to get a status on multiple modules and would only require to "catch" the Maven failure at the end of the build.
Having a final Maven build FAILED translated to Jenkins build UNSTABLE would avoid the unwanted execution of other plugins after surefire or failsafe detected the failure.
Consistency with Freestyle job
For consistency purpose, the 'Publish JUnit test result report' post build step should be able to switch the Jenkins build result from FAILURE to UNSTABLE when the BUILD failure is only due to Maven tests failure.
|