How to specify Clover CoverageTarget Metrics in Jenkins Pipeline? How to specify Clover CoverageTarget Metrics in Jenkins Pipeline? jenkins jenkins

How to specify Clover CoverageTarget Metrics in Jenkins Pipeline?


Example:

step([  $class: 'CloverPublisher',  cloverReportDir: 'target/site',  cloverReportFileName: 'clover.xml',  healthyTarget: [methodCoverage: 70, conditionalCoverage: 70, statementCoverage: 70], // optional, default is: method=70, conditional=80, statement=80  unhealthyTarget: [methodCoverage: 50, conditionalCoverage: 50, statementCoverage: 50], // optional, default is none  failingTarget: [methodCoverage: 0, conditionalCoverage: 0, statementCoverage: 0]     // optional, default is none])

Reference: https://wiki.jenkins-ci.org/display/JENKINS/Clover+Plugin


I think your shoud use

step([$class: 'CloverPublisher', cloverReportDir: 'target/site/clover', cloverReportFileName: 'clover.xml'])


So the solution i got working is:

in your package.json, define these tasks:

"test": "mocha test/  && npm run-script coverage","coverage": "npm run-script analyze-coverage && npm run-script check-coverage","analyze-coverage": "istanbul cover _mocha -- -R tap test/*.js  > test.tap && istanbul report clover","check-coverage": "istanbul check-coverage --lines 80"

Now npm test will fail if the code coverage (of lines) is less than 80% (see istanbul npm module for more options)

This actually removes the dependency of specifying the threshold in Clover Plugin and thus solves the issue.

ThanksRamya