How to get Jenkins to -fail-fast on Maven 2 builds?

advertisements

I am trying to build a multi-module Maven project using Jenkins.

When I build the same project on the command-line using the same environment (variables/settings.xml/user) as Jenkins does, test failures cause the build to fail immediately:

Failed tests:
  testSomething(com.package_name.TestSomethingOrTheOther)

Tests run: .., Failures: 1, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] There are test failures.
...
# Build fails immediately

Where-as when building in Jenkins:

Failed tests:
  testSomething(com.package_name.TestSomethingOrTheOther)

Tests run: .., Failures: 1, Errors: 0, Skipped: 0

[ERROR] There are test failures.
...
# Build continues to other modules
...
[INFO] Reactor Summary:
[INFO] ------------------------------------------------------------------------
[INFO] parent ................................................ SUCCESS [.....s]
[INFO] module-that-failed .................................... SUCCESS [.....s]
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------

The build states that all modules and parent are SUCCESS-ful, when in reality, these should be failures.

How do I get Jenkins to enforce fail-fast in maven builds as maven does in the command-line?

Thanks in advance.


Jenkins ignores test failures by default, and then marks the build as unstable if they were any.

The parameter that controls that is: testFailureIgnore (see surefire plugin doc)

I've never tried that, but I would attempt to override that setting on the jenkins job configuration:

-Dmaven.test.failure.ignore=false