Scoobie
Scoobie

Reputation: 1139

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

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.

Upvotes: 3

Views: 4208

Answers (2)

ptyx
ptyx

Reputation: 4164

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

Upvotes: 9

malenkiy_scot
malenkiy_scot

Reputation: 16615

You can specify MAVEN_OPTS if you click on Advanced button in the Build section.

Upvotes: 1

Related Questions