- Overview
- Supports coverage reports
- How to use
- How to use with Jenkins Pipelines
- Troubleshooting
- Changelog
Parse code coverage report generated by build and post code coverage status comment to Bitbucket pull request:
- Jacoco
jacoco.xml
- Cobertura
cobertura.xml
orcobertura-coverage.xml
- Clover
clover.xml
- SimpleCov JSON (Ruby)
coverage.json
- Install plugin from Jenkins Plugin Repository
- Or manually
To be able compare Pull Request coverage plugin needs master/reference coverage for Bitbucket repository.
- Add Record Master Coverage post build step to build which tests your master/target branches. Coverage will be stored per repository URL and branch name.
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.
- Goto
Manage Jenkins
- Find section
Coverage status for Bitbucket Pull Requests
- Fill
Sonar URL
field - e.g.http://sonar.mycompany.com
- Turn On
Use Sonar for master coverage
- Optionally use can specify your personal
Sonar access token
. - The next pull request build will use SonarQube as the the source for master coverage
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.
- To Jenkins Job triggered by Bitbucket pull request builder plugin add Publish coverage to Bitbucket post build step
- Ensure that build create code coverage report file
- To Jenkins Job triggered by Branch API Plugin add Publish coverage to Bitbucket post build step
- Ensure that build create code coverage report file
- Before
Publish coverage to Bitbucket
step injectCHANGE_ID
andCHANGE_URL
to build envs where first one is Pull Request ID (number) and second link to repository - Add Publish coverage to Bitbucket post build step to build
- Ensure that build create code coverage report file
- After running tests set build result to Success
currentBuild.result = 'SUCCESS'
- Trigger MasterCoverageAction to collect master coverage
step([$class: 'MasterCoverageAction'])
- Trigger CompareCoverageAction to compare coverage and publish results
step([$class: 'CompareCoverageAction'])
- Optionally use can specify here sonar login and sonar password like this:
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:
- Goto
Jenkins Configuration
- Turn on
Jenkins is not accessible for Bitbucket
- Done next coverage comment in Pull Request will use http://shields.io
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:
- Configure Jenkins to be accessible for
https
https://wiki.jenkins-ci.org/display/JENKINS/Starting+and+Accessing+Jenkins - Next you have a few options:
- Run your Jenkins on
https
only - Or configure plugin to publish link on picture over
https
- Open Jenkins
- Click
Manage Jenkins
- Click
Configure System
- Find section
Coverage status for Bitbucket Pull Requests
- Find property
Jenkins URL for icon in Pull Request
- Put URL to your Jenkins with
https
likehttps://jenkins.my.com
- Save
- Find section
- Restart Jenkins
- Forked project from github-pr-coverage-status-plugin to bitbucket-pr-coverage-status-plugin
- Moved global plugin variables to job specific ones
- Stores branch name with coverage to support multi branch coverage reports
- Add parameter "decreased coverage is red"
- Allow to disable SimpleCov Coverage parser
- Add support of Workflow SCM Step Plugin
- Fix Master showing 0% even after RecordMasterCoverage is run
- Sonar token & login/password authentication
- SimpleCov JSON report fix coverage
- Support of https://github.com/jenkinsci/branch-api-plugin
- Support for Jenkins Pipeline
- Support single quotes for Cobertura Report
- Cobertura plugin ignores zero for
lineRate
orbranchRate
as resultlineRate=0 branchRate=0.5 => Coverage 25%
became0.5
aslineRate=0
, same policy forbranchRate
- Log Enchacements
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