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
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • How To Use Docker Volume To Build Angular Application With Jenkins Pipeline
  • What Do You Mean by Debugging in C?
  • GitLab vs Jenkins: Which Is the Best CI/CD Tool?
  • Streamlining Your Workflow With the Jenkins HTTP Request Plugin: A Guide to Replacing CURL in Scripts

Trending

  • Build a Serverless App Fast With Zipper: Write TypeScript, Offload Everything Else
  • How To Validate Archives and Identify Invalid Documents in Java
  • How To Verify Database Connection From a Spring Boot Application
  • Analyzing Stock Tick Data in SingleStoreDB Using LangChain and OpenAI's Whisper
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. JaCoCo Jenkins Plugin

JaCoCo Jenkins Plugin

Alex Soto user avatar by
Alex Soto
·
Aug. 14, 12 · Tutorial
Like (3)
Save
Tweet
Share
56.87K 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, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • How To Use Docker Volume To Build Angular Application With Jenkins Pipeline
  • What Do You Mean by Debugging in C?
  • GitLab vs Jenkins: Which Is the Best CI/CD Tool?
  • Streamlining Your Workflow With the Jenkins HTTP Request Plugin: A Guide to Replacing CURL in Scripts

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: