DevOps Zone is brought to you in partnership with:

Alex Soto discovered Java during second year of his studies in computer science and wrote his Master's Thesis on Emergent Intelligence applied to Data Mining, winning the second prize of Hermano Salvador González contest. During his 11 years of software development, Alex has worked in several companies as technical consultant, and currently is working as technical analyst at a major international pharmaceutical company developing in-vitro medical software meeting FDA standards, where performance and safety is "a must". Alex also works as tutor at Open University of Catalonia (UOC), teaching Compilers course. He spends his free time to write in his blog ( where some posts are published in sites like dzone, theserverside and springsource. Alex has spoken at Devoxx 2011 and Linuxtag 2012. Currently is developing NoSQLUnit, a JUnit extension for testing NoSQL systems. Alex is a DZone MVB and is not an employee of DZone and has posted 32 posts at DZone. You can read more from them at their website. View Full User Profile

JaCoCo Jenkins Plugin

  • submit to reddit

In my post about JaCoCo and Maven I 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:


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 JaCoCo XML 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,
Published at DZone with permission of Alex Soto, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)