I\'m using Jenkins, Maven 3.1, and Java 1.6. I have the following Maven job set up in Jenkins with the following goals and options ...
clean install -U -P c
Another hack that can be useful is to use groovy post-build to check and set test result.
e.g. this groovy gets build result, appends useful things to build description and sets build result to UNSTABLE in the case that there are no pass or fail but all tests skipped.
def currentBuild = Thread.currentThread().executable
// must be run groovy post-build action AFTER harvest junit xml if you use junit xml test results
testResult1 = currentBuild.testResultAction
currentBuild.setDescription(currentBuild.getDescription() + "\n pass:"+testResult1.result.passCount.toString()+", fail:"+testResult1.result.failCount.toString()+", skip:"+testResult1.result.skipCount.toString())
// if no pass, no fail all skip then set result to unstable
if (testResult1.result.passCount == 0 && testResult1.result.failCount == 0 && testResult1.result.skipCount > 0) {
currentBuild.result = hudson.model.Result.UNSTABLE
}
currentBuild.setDescription(currentBuild.getDescription() + "\n" + currentBuild.result.toString())
def ws = manager.build.workspace.getRemote()
myFile = new File(ws + "/VERSION.txt")
desc = myFile.readLines()
currentBuild.setDescription(currentBuild.getDescription() + "\n" + desc)
Use Text Finder plugin. Configure it to look for There are test failures
and downgrade the build to FAILED
You can add -Dmaven.test.failure.ignore=false
to the MAVEN_OPTS
if you click on Advanced button in the Build section of your Jenkins Job.
See Maven Surefire Plugin - surefire:test options for reference.