Table of Contents |
---|
Introduction
Jacoco is a Java code coverage tool which measures your code coverage, generates helpful HTML pages, can enforce minimum line and branch coverage in the build. It can be integrated with Jenkins so you can view all coverage metrics for your project.
Jacoco has been added to Synapse-Repository-Services, but it can be added to any Java Maven project.
...
Enabling JaCoCo in Jenkins
There are two ways to view the Jacoco reports in your jenkins build:
Using the JaCoCo Jenkins Plugin
Using the maven plugin itself
JaCoCo Jenkins Plugin
You can enable a post-build action for your build that generates a report integrated into Jenkins and that shows the coverage report within Jenkins as well as a graph with the coverage over time of your builds:
...
The plugin can be configured in your build adding a new post build action. Go to your project and click “Configure”, scroll down to the “Post-build Actions” section and add the “Record JaCoCo Coverage Report“:
...
The plugin needs to be configured with the path of the class directories pointing to “**/target/classes“:
...
When a new build is run, the coverage report and the coverage trend will appear in the build page:
...
JaCoCo Maven Plugin on Jenkins
To enable Jacoco in your devp* build in Jenkins, you’ll need to enable build artifacts in your project. Go to your project, click “Configure”, and scroll down to “Post-build Actions”. Add the “Archive the artifacts” action and set “Files to archive” to “**/*” (that is, everything). (Note the terminology. In this case “archive” means “save the artifacts so they’re available for me to look at after the build is done.)
...