DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • How to Use Jenkins Effectively With ECS/EKS Cluster
  • Beyond Code Coverage: A Risk-Driven Revolution in Software Testing With Machine Learning
  • Mastering Shift-Left: The Ultimate Guide to Input Validation in Jenkins Pipelines
  • Integrating Jenkins With Playwright TypeScript: A Complete Guide

Trending

  • How Reactive Scaling Drains Your Cloud Budget Without Warning
  • Multi-Scale Feature Learning in CNN and U-Net Architectures
  • Top JavaScript/TypeScript Gen AI Frameworks for 2026
  • GenAI Implementation Isn't Magic — It’s a Lifecycle
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. JaCoCo Jenkins Plugin

JaCoCo Jenkins Plugin

By 
Alex Soto user avatar
Alex Soto
·
Aug. 14, 12 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
58.5K Views

Join the DZone community and get the full member experience.

Join For Free


In my post about JaCoCo and MavenI wrote about the problems of using the JaCoCo Maven plugin in multimodule Maven projects because of having one report for each module separately instead of one report for all modules, and how it can be fixed using JaCoCo Ant Task.


In this post we are going to see how to use the JaCoCo Jenkins plugin to achieve the same goal of Ant Tasks and have overall code coverage statistics for all modules.


The first step is installing the JaCoCo Jenkins plugin.


Go to Jenkins -> Manage Jenkins -> Plugin Manager -> Available and find JaCoCo Plugin


The next step, if it is not done already, is configuring your JaCoCo Maven plugin into parent pom:

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

And finally a post-action must be configured to the job responsible for packaging the application. Note that in previous pom file reports are generated just before the package goal is executed.

Go to Configure -> Post-build Actions -> Add post-build action -> Record JaCoCo coverage report.

Then we have to set folders or files containing JaCoCoXML reports, which are using the previous pom to **/target/site/jacoco/jacoco*.xml, and also set when we consider that a build is healthy in terms of coverage.


Then we can save the job configuration and run the build project.


After the project is build, a new report will appear just under the test result trend graph, called code coverage trend, where we can see the code coverage of all project modules.



From the left menu, you can enter into Coverage Report and see code coverage of each module separately.



Furthermore, visiting the Jenkins main page will give you a nice quick overview of a job when you mouse over the weather icon as shown:



Keep in mind that this approach for merging code coverage files will only work if you are using Jenkins as a CI system.  Ant Task is a more generic solution and can also be used with the JaCoCo Jenkins plugin.


We Keep Learning,

Alex.

Jenkins (software) Code coverage

Published at DZone with permission of Alex Soto. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • How to Use Jenkins Effectively With ECS/EKS Cluster
  • Beyond Code Coverage: A Risk-Driven Revolution in Software Testing With Machine Learning
  • Mastering Shift-Left: The Ultimate Guide to Input Validation in Jenkins Pipelines
  • Integrating Jenkins With Playwright TypeScript: A Complete Guide

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook