Jenkins – Mark Gradle build unstable in Jenkins when JUnit tests fail

gradleJenkinsjunit

I have a Gradle build in Jenkins with various JUnit tests that are executed as part of the build. Now when some of the tests fail the complete build is marked as failed – because Gradle says the build failed.

How can I convince Gradle to succeed the build and then Jenkins to mark the build as unstable? With ant this was no problem at all.

Best Answer

Use the ignoreFailures property in the test task.

apply plugin: 'java'
test {
     ignoreFailures = true
}