Parse code coverage report generated by build and post code coverage status comment to Bitbucket pull request:
jacoco.xml
cobertura.xml
or cobertura-coverage.xml
clover.xml
coverage.json
To be able compare Pull Request coverage plugin needs master/reference coverage for Bitbucket repository.
You have the option to get the master coverage (base coverage) from your SonarQube instance. Otherwise the plugin will keep track of the master coverage in the project configuration file.
Manage Jenkins
Coverage status for Bitbucket Pull Requests
Sonar URL
field - e.g. http://sonar.mycompany.com
Use Sonar for master coverage
Sonar access token
. The plugin will try to find the project in SonarQube based on the repository name. If more than one projects match, a warning is logged, and the first one will be used to get the coverage data.
Depends on plugin which you are using to run (trigger) pull request in Jenkins.
Publish coverage to Bitbucket
step inject CHANGE_ID
and CHANGE_URL
to build envs
where first one is Pull Request ID (number) and second link to repositorycurrentBuild.result = 'SUCCESS'
step([$class: 'MasterCoverageAction'])
step([$class: 'CompareCoverageAction'])
step([$class: 'CompareCoverageAction', sonarLogin: "login", sonarPassword: "password"])
Because of that Bitbucket can't render icon picture hosted on Jenkins. Plugin can use http://shields.io public resource instead of Jenkins hosted picture. To use it:
Jenkins Configuration
Jenkins is not accessible for Bitbucket
If you see next picture on your pull request in Bitbucket:
In most cases that mean that your Jenkins runs on http
instead of https
Plugin uses same protocol as your Jenkins, however Bitbucket in most cases accessible by https
Default browser policy to block non secure resources on secure pages from unknown domain.
To fix that:
https
https://wiki.jenkins-ci.org/display/JENKINS/Starting+and+Accessing+Jenkinshttps
onlyhttps
Manage Jenkins
Configure System
Coverage status for Bitbucket Pull Requests
Jenkins URL for icon in Pull Request
https
like https://jenkins.my.com
lineRate
or branchRate
as result lineRate=0 branchRate=0.5 => Coverage 25%
became 0.5
as lineRate=0
, same policy for branchRate
Supporting Master Coverage from SonarQube. Check (details)[#master-coverage-from-sonar]
Supporting of private Jenkins with public Bitbucket. To enable that mode goto Jenkins Configuration and turn on Jenkins is not accessible for Bitbucket
Add support SimpleCov JSON coverage report for Ruby
Add alternative text to coverage image for case when Bitbucket doesn't able to show image
Correct parsing Cobertura report for edge cases
First public release to Jenkins Plugin Repo