Change By: Julien Carsique (10/Sep/14 11:38 PM)
Description: Following the Jenkins [Terminology|https://wiki.jenkins-ci.org/display/JENKINS/Terminology], when (surefire or failsafe) tests fail, the Jenkins build status must be UNSTABLE:
<<  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. >>

h4. Maven job

That is the default case on Maven jobs; the code of https://github.com/jenkinsci/maven-plugin/blob/maven-plugin-2.6/src/main/java/hudson/maven/reporters/SurefireArchiver.java#L88 uses the {{-Dmaven.test.failure.ignore=true}} option:
- *the Maven execution is not interrupted by a test failure*
- Maven build is SUCCESS
- Jenkins build is UNSTABLE

However, that is a few error-prone and inconsistent with the command line or Freestyle job Maven execution. 
That would be highlighted by a Jenkins option to switch on or off that feature, rather than the need to know one must pass {{-Dmaven.test.failure.ignore=false}} to deactivate it.

The error-prone aspect comes from the build continuation, which will for instance install the artifacts:
{noformat}
[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ test-jenkins-failures ---
[ERROR] There are test failures.
[INFO] --- maven-failsafe-plugin:2.17:integration-test (default) @ test-jenkins-failures ---
[INFO] --- maven-failsafe-plugin:2.17:verify (default) @ test-jenkins-failures ---
[ERROR] There are test failures.
[INFO] --- maven-install-plugin:2.5.1:install (default-install) @ test-jenkins-failures ---
[INFO] Installing ...
[INFO] BUILD SUCCESS
Finished: UNSTABLE{noformat}
So, it is recommended in a Maven job to call the {{package}
 phase } or {{verify}} phases  rather than {{install}} or {{deploy}} and use the post-build steps to deploy the artifacts at the end (the new deployAtEnd Maven option is an alternative).

It would be nice if there was a way to alternatively use for instance the {{-
Dmaven.test.failure.ignore=false}} parameter and the {{- fae}} Maven 3 option ("Only fail the build afterwards; allow all non-impacted builds to continue")  and  but  get the final Maven build FAILED translated to Jenkins build UNSTABLE.  For consistency with the terminology . .

h4. Freestyle job

About the Maven build step in Freestyle jobs, they do not behave that way by default. The result is the same as an execution from command line:
- Maven execution is interrupted by tests failures
- Maven build is FAILURE
- Jenkins build is FAILURE

Reproducing the Maven job behavior is possible with the {{-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).

As for the Maven job, it would be great if the 'Publish JUnit test result report' post build step would be able to switch the Jenkins build result from FAILURE to UNSTABLE when the BUILD failure is only due to Maven test failures.
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira

--
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to