Reputation: 8163
I want to reduce the load on our Jenkins slaves and give developers a quicker feedback when there are checkstyle/findbugs issues. Currently the build runs through, but is still marked as failed if there are checkstyle issues.
stage ('Reports') {
step([$class: 'FindBugsPublisher', canComputeNew: false, canRunOnFailed: true, defaultEncoding: '', excludePattern: '', failedTotalHigh: '0', failedTotalNormal: '200', failedTotalLow: '350', healthy: '', includePattern: '', pattern: '**/spotbugsXml.xml', unHealthy: ''])
step([$class: 'CheckStylePublisher', canComputeNew: false, canRunOnFailed: true, defaultEncoding: '', healthy: '', pattern: '**/maven_checks.xml ',failedTotalHigh: '0', failedTotalNormal: '0',failedTotalLow: '0', unHealthy: ''])
step([$class: 'WarningsPublisher', canComputeNew: false, canResolveRelativePaths: false, consoleParsers: [[parserName: 'Maven'], [parserName: 'userdef-protobuf'], [parserName: 'userdef-xtend']], defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', unHealthy: ''])
}
I want this stage to fail the build immediately if there were problems, and not wait until the end of the tests etc. Currently subsequent stages are still executed.
Upvotes: 1
Views: 458
Reputation: 2960
I ran into the same issue and as lame as it seems, I currently do a simple grep
on my checkstyle.xml
to see if there are errors, and fail te build if so:
def foundErrors = sh(
script: "cat test-reports/checkstyle.xml | grep 'severity=\"error\"' | wc -l",
returnStdout: true
)
if (foundErrors.toInteger() > 0) {
error("Build failed because of errors in static code analysis.")
}
I know, it's very lame, but in my case it does the job. Not sure if this is helpful for you since I have only 1 XML file to worry about and that does not seem te be the case for you, but hey, at least it's something ;-)
Upvotes: 1