1

Given the following code using rtMaven and assuming there are test failures

try{
rtMaven.run pom: 'pom.xml', goals: '-B clean install '
}catch(e){
    println "test failures?"
}

the build status is set to FAILURE although the exception is caught. Is there any possibility to prevent this and setting to build to UNSTABLE only?

Currently I am doing

rtMaven.run pom: 'pom.xml', goals: '-B clean install -Dmaven.test.failure.ignore=true'

if (manager.logContains(".*There are test failures.*")) {
    currentBuild.result = 'UNSTABLE'
}

but obviously this is a fragile workaround...

user140547
  • 7,750
  • 3
  • 28
  • 80
  • You could try manually setting the build status inside the catch block `currentBuild.result = 'UNSTABLE'` – Sergej Lopatkin Jan 24 '18 at 10:21
  • 2
    @SergejLopatkin: unfortunately this does not work (https://stackoverflow.com/a/38735701/4945535): currentBuild.result can only get worse. If that value was previously FAILED and receives a new status SUCCESS through currentBuild.result = 'SUCCESS' it will stay FAILED – user140547 Jan 24 '18 at 10:26
  • Thanks for the information, that is new to me. I suggest you then use the maven flag `-Dmaven.test.failure.ignore=true'` like in the first snippet. – Sergej Lopatkin Jan 24 '18 at 13:53

0 Answers0