Jenkins JaCoCo Plugin
A plugin for Jenkins to capture and visualize code coverage testing results for projects using JaCoCo for code-coverage analysis.
More information can be found on the Wiki page https://wiki.jenkins-ci.org/display/JENKINS/JaCoCo+Plugin
Available options are described at https://www.jenkins.io/doc/pipeline/steps/jacoco/
Note: Version 2.0.0 and higher requires using JaCoCo 0.7.5 or newer, if your projects still use JaCoCo 0.7.4, the plugin will not display any code-coverage numbers any more! In this case please use version 1.0.19 until you can update jacoco in your codebase.
The following is an example snippet that can be used in a Jenkinsfile
post {
success {
jacoco(
execPattern: '**/build/jacoco/*.exec',
classPattern: '**/build/classes/java/main',
sourcePattern: '**/src/main'
)
}
}
See https://www.jenkins.io/doc/pipeline/steps/jacoco/ for the list of available options.
When looking for things to work at there are pull requests and a list of Jenkins Issues.
In general the plugin is currently in "minimal maintenance" mode, i.e. no larger development is done due to the small number of active contributors and general time constraints.
Please speak up if you are interested in helping to maintain this plugin!
There is a developer list at https://groups.google.com/forum/#!forum/jenkins-jacoco-plugin-mailing-list, it is usually very low volume.
Plugin source code is hosted on GitHub.
New feature proposals and bug fix proposals should be submitted as GitHub pull requests.
Fork the repository on GitHub, prepare your change on your forked copy, and submit a pull request (see here for open pull requests). Your pull request will be evaluated by this job.
Before submitting your change, please assure that you've added a test which verifies your change. There have been many developers involved in the jacoco plugin and there are many, many users who depend on the jacoco-plugin. Tests help us assure that we're delivering a reliable plugin, and that we've communicated our intent to other developers in a way that they can detect when they run tests.
Code coverage reporting is available as a maven target and is actively monitored. Please try your best to improve code coverage with tests when you submit.
Before submitting your change, please review the output of the checks that run in CI at https://ci.jenkins.io/job/Plugins/job/jacoco-plugin/ to assure that you haven't introduced new warnings.
mvn package
mvn hpi:run
See https://jenkinsci.github.io/maven-hpi-plugin/ for details.
Rolling a release requires you to set up a few additional things:
Run with Java 11 to not push code compiled with a newer version of Java
Github authentication should work via SSH, username used should be "git", it should use one of the local private SSH keys which should be uploaded to Github, see https://github.com/settings/keys, test via
ssh -T [email protected]
You should get back a line containing You've successfully authenticated
Jenkins-CI authentication should work via settings in
~/.m2/settings.xml
, see http://maven.apache.org/guides/mini/guide-encryption.html
for details
The mvn-calls below should not require "username" or "password", if they do ask for it, then some setup is incorrect
Apache Maven 3.8.1 or newer is required
Check that all tests pass ("mvn findbugs:check" and "mvn checkstyle::check" report violations but are not blocking releases for now...)
mvn clean package && mvn validate
Manually test the plugin
mvn hpi:run
Go to http://localhost:8080/jenkins/ and perform some testing
Prepare the release
mvn release:prepare -DskipTests -Dmaven.test.skip=true
This will ask for the release numbers and the tag in the source control system.
Roll the release
mvn release:perform -DskipTests -Darguments="-DskipTests" -Dmaven.test.skip=true
This should perform the actual uploads of the resulting binary packages.
Update release notes at https://github.com/jenkinsci/jacoco-plugin/tags
Release should be visible immediately at https://repo.jenkins-ci.org/releases/org/jenkins-ci/plugins/jacoco/
Release is published after some time at https://mvnrepository.com/artifact/org.jenkins-ci.plugins/jacoco?repo=jenkins-releases
See also general documentation about releasing Jenkins plugins:
This plugin allows you to capture code coverage report from JaCoCo. Jenkins will generate the trend report of coverage and some other statistics.
It also includes functionality to include columns in Dashboards which displays the latest overall coverage numbers and links to the coverage report.
The plugin provides two things, a build-publisher to record and display coverage data as part of builds as well as a new column-type for dashboard views which can display coverage data in Dashboards.
First you need to get coverage calculated as part of your build/tests,
see the JaCoCo
documentation
for details. You need at least one or more *.exec file available after
tests are executed. Usually this means adjusting
your Maven pom.xml or Ant build.xml file..
In order to get the coverage data published to Jenkins, you need to add
a JaCoCo publisher and configure it so it will
find all the necessary information. Use the help provided via the
question-mark links for more information. Basically
you specify where the *.exec files are, where compiled code can be
found and where the corresponding source code is
located after the build is finished to let the plugin gather all
necessary pieces of information..
After the job executed, the build-output will show that the
JaCoCo-publisher is executed and collects the data. This
output can also give hints if something goes wrong at this stage:
Zeichne Testergebnisse auf.
[JaCoCo plugin] Collecting JaCoCo coverage data...
[JaCoCo plugin] build/*.exec;build/*-classes;src/java,src/*/java,src/*/src; locations are configured
[JaCoCo plugin] Number of found exec files: 5
[JaCoCo plugin] Saving matched execfiles: .../build/jacoco-excelant.exec .../build/jacoco-main.exec .../build/jacoco-ooxml-lite.exec
[JaCoCo plugin] Saving matched class directories: .../build/examples-classes .../build/excelant-classes .../build/excelant-test-classes
[JaCoCo plugin] Saving matched source directories: .../src/contrib/src .../src/examples/src .../src/excelant/java .../src/java
[JaCoCo plugin] Loading inclusions files..
[JaCoCo plugin] inclusions: []
[JaCoCo plugin] exclusions: [**/Test*]
[JaCoCo plugin] Thresholds: JacocoHealthReportThresholds [minClass=0, maxClass=0, minMethod=0, maxMethod=0, minLine=0, maxLine=0,
minBranch=0, maxBranch=0, minInstruction=0, maxInstruction=0, minComplexity=0, maxComplexity=0]
[JaCoCo plugin] Publishing the results..
[JaCoCo plugin] Loading packages..
[JaCoCo plugin] Done.
If data gathering is successful, the build will include a link to the
coverage results similar to the HTML report of
JaCoCo itself. The job page will be enhanced with a chart with the trend
of code coverage over the last builds.
This part of the JaCoCo plugin allows you to add a new type of column to
a project-table in the Dashboard view which
will show the coverage number of the last build for ajob together with
some color coding which allows to quickly see
projects with low coverage.
The fill-color in use by the column is a continuous color-range with the following points:
See the Jenkins JIRA
For current versions see the changelog in the release-area at https://github.com/jenkinsci/jacoco-plugin/releases
Core JaCoCo plugin
Core JaCoCo plugin
Coverage column: