A Jenkins 2.0 Pipeline library for automatically posting code coverage results to GitHub pull requests.
Currently supports:
- input
- jacoco xml
- output
- github.com
- github enterprise
In your Jenkinsfile:
@Library('github.com/spotify/[email protected]') _
stage("Run tests") {
sh "mvn test"
}
stage("Post coverage") {
postJacocoCoverage(threshold: 75)
}
threshold
: your code coverage must be at or above this level to get a passing scoredeltaThreshold
(optional): your code coverage must have changed by at least this much to get a passing score- if not specified, coverage delta will not be computed and pull request status will not be affected
- for example, setting
deltaThreshold: -1.0
will cause the pull request to be marked red if your changes result in a drop of more than 1% coverage (as compared to the coverage in the master branch)
xmlPath
(optional): the location of the jacoco coverage xml file- defaults to
target/site/jacoco/jacoco.xml
- defaults to
This library uses total instruction coverage for all code coverage calculations. Note that this is different from line coverage and branch coverage.
- jenkins 2.0+
- bash 4.0+
- python 2.6+
- maven, sbt, or something else that can generate jacoco reports
In addition, in Jenkins there must be a defined Credential called github-user-token
, containing as password a valid GitHub api token. The Credential username can be anything, as it is not used. The token's permissions must allow read access to repositories and posting comments to pull requests at minimum.
This project adheres to the Open Code of Conduct. By participating, you are expected to honor this code.