Skip to end of metadata
Go to start of metadata

Plugin Information

View JaCoCo on the plugin site for more information.

Unfortunately JaCoCo 0.7.5 breaks compatibility to previous binary formats of the jacoco.exec files. The JaCoCo plugin up to version 1.0.19 is based on JaCoCo 0.7.4, thus you cannot use this version with projects which already use JaCoCo 0.7.5 or newer. JaCoCo plugin starting with version 2.0.0 uses JaCoCo 0.7.5 and thus requires also this version to be used in your projects. Please stick to JaCoCo plugin 1.0.19 or lower if you still use JaCoCo 0.7.4 or lower

Basic information
This plugin allows you to capture code coverage report from JaCoCo. Jenkins will generate the trend report of coverage.

This plugin is fork of the Emma Plugin. Big part of the code structure comes from it, however, it is completely refactored.

It also includes functionality similar to the Emma Coverage Column which allows to include a column in Dashboards
which displays the latest overall coverage numbers and links to the coverage report.

Getting Started

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.

Recording coverage for builds

Get coverage data as part of your build

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..

Set up coverage retrieval and publishing

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..

Run the job

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.
Look at results

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.

Coverage column

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:

  • PERFECT = 100.0
  • EXCELLENT at 97.0
  • GOOD at 92.0
  • SUFFICIENT at 85.0
  • FAIR at 75.0
  • POOR at 50.0
  • TRAGIC at 25.0
  • ABYSSMAL at 0.0
  • NA = No coverage configured

Open Tickets (bugs and feature requests)

See https://issues.jenkins-ci.org/browse/JENKINS-42420?jql=project%20%3D%20JENKINS%20AND%20status%20in%20(Open%2C%20%22In%20Progress%22%2C%20Reopened%2C%20%22In%20Review%22)%20AND%20component%20%3D%20jacoco-plugin

Build Status


Change Log

Version 3.1-SNAPSHOT (unreleased)

  • N/A

Version 3.0 (February 18, 2018)

  • No change upload due to problems with the release-workflow

Version 3.0 (February 18, 2018)

Version 2.2.1 (May 5, 2017)

 

  • JENKINS-43103 Removed dependency on Joda Time 
  • #83 Added symbol name for better pipeline integration
  • JENKINS-41515   Update Jenkins parent to 1.625.3 to be able to test with current pipeline-plugin
  • JENKINS-41515 Adjust dependencies and add some exclusions to remove a number of unnecessary jars from the resulting hpi file

Version 2.2.0 (Mar 22, 2017)

  • Configuration: Put checkboxes on top of threshold values in the configuration UI
  • #81 New flag to enable/disable display of source files with line coverage highlights
  • #80 Allow to fail the build if coverage degrades to much compared to previous build
  • #79/JENKINS-25076/JENKINS-29117 Report 100% for empty Coverage objects
  • #78/JENKINS-26254 Use BufferedInputStream to read .exec files
  • #76 Allow usage of environment variables in threshold fields.
  • JENKINS-38604: Limit copying of files to types *.java and *.class
  • JENKINS-36571: Update to Java 1.7
  • JENKINS-36536: Put a trend graph on the pipeline project page
  • JENKINS-32847: Add warning for sub directory filter
  • JENKINS-16787: Add shape and center plot for single-build-graphs

Version 2.1.0 (Sep 29, 2016)

  • JENKINS-16580 Display more than only line coverage in graph, #50
  • JENKINS-27120 Adding Workflow support for JaCoCo publisher, make JacocoPublisher a SimpleBuildStep, #63, #66, #70, #72, #73
  • Handle Jenkins publisher case when classes directory is empty, #67
  • JENKINS-32717 Multiple class directories and source directories not parsed if there is a space after comma delimiter, #68
  • Use full precision when comparing coverage to thresholds, #71
  • Expand the inclusion and exclusion inputs, #74

Version 2.0.1 (Jan 15, 2016)

  • Fix the m2e lifecycle-mapping, #64
  • Integrate automated builds via travis-ci and show the build-state on the github page
  • Fix for JENKINS-31751 JaCoCo 2.0.0 plugin shows html instead of coverage report chart

Version 2.0.0 (Nov 23, 2015)

  • Major version change because the jacoco.exec file from the newer JaCoCo is binary incompatible with previous builds
  • Update to JaCoCo 0.7.5, this causes binary incompatibility! See #55
  • Add coverage summary on build status/result page. Thanks to Felipe Brandão for the patch, see #61

 

 Older changelog

Version 1.0.19 (Apr 7, 2015)

  • Update used version of JaCoCo to 0.7.4

Version 1.0.18 (Dec 7, 2014)

  • Fix JENKINS-23708 NullPointerException if older JaCoCo reports are opened

Version 1.0.17 (Nov 25, 2014)

Version 1.0.16 (Jun 24, 2014)

Version 1.0.15 (Jun 11, 2014)

Version 1.0.14 (Nov 9, 2013)

Core JaCoCo plugin

Version 1.0.13 (Aug 22, 2013)

Core JaCoCo plugin

Coverage column:

Version 1.0.12 (Feb 22, 2013)

Version 1.0.11 (Feb 21, 2013)

Version 1.0.10 (Feb 05, 2013)

Version 1.0.9 (Nov 18, 2012) 

Version 1.0.8 (Okt 15, 2012) 

Version 1.0.7 (Okt 8, 2012) 

Version 1.0.6 (Okt 2, 2012) 

Version 1.0.5 (Sep 09, 2012) 

  • Fixed JENKINS-15088: When the missed count is bigger than the covered, the redbar becomes too long

Version 1.0.4 (Sep 03, 2012) 

  • Fixed JENKINS-14896: java.io.FileNotFoundException when saving module data

Version 1.0.3 (Aug 20, 2012) 

  • New concept implemented JENKINS-14927: Use the EXEC files instead the XMLs
  • Fixed JENKINS-14279: Report "missed items" rather that coverage percentage
  • Fixed JENKINS-14159: 404 when trying to see coverage on java code (implementation of sourcefile highlighting)
  • New feature JENKINS-14274: Multi module reporting

Version 1.0.2 (Jul 01, 2012) 

  • Fixed JENKINS-14270: The report does not show the covered/all, it shows something different

Version 1.0.1 (Jun 25, 2012) 

  • Fixed testcases to have all the tests passed for a release
  • Fixed JENKINS-14203: The total summary is double counted

Version 1.0.0 (Jun 14, 2012) 

  • Fixed 3 testcases to have all the tests passed for a release
  • Fixed POM: making it releasabl

21 Comments

  1. What is the planned release date of 1.0.17 ?

  2. https://issues.jenkins-ci.org/browse/JENKINS-25754

    If I configure in a view the Line Coverage column, the link to the Jacoco Line coverage results is wrong.

    the link includes 2 times "/view/OTTV/view/OTTV":

    http://cssincm.gud.siemens.at:8181/view/OTTV/view/OTTV/job/OTTV.MMSE-SearchDataCrawler.V3.0/lastSuccessfulBuild/jacoco/

    1. This is already fixed in latest github version, please use JIRA or the mailing list to discuss issues, not this documentation page.

  3. hi , why i always get coverage be 0 , but actually i have a lot of test cases.

    1. Please ensure that you use jacoco-plugin-2.0.1 on Jenkins and JaCoCo 0.7.5 in your project when running code-coverge to have matching library versions.

  4. My Jenkins  server started throw below and the hung up.

    [JaCoCo plugin] Loading packages..
    [JaCoCo plugin] Loading packages..
    May 25, 2016 11:10:08 AM org.eclipse.jetty.util.log.JavaUtilLog warnWARNING: Error while serving http://hostURL/job/Test_PROJECT/lastBuild/jacoco/path_to_class/graph
    java.lang.reflect.InvocationTargetException        
    at sun.reflect.GeneratedMethodAccessor1341.invoke(Unknown Source)

    May 25, 2016 11:10:08 AM org.eclipse.jetty.util.log.JavaUtilLog warn
    WARNING: Error while serving http://hostURL/job/Test_PROJECT/lastBuild/jacoco/path_to_Class/graph
    java.lang.reflect.InvocationTargetException
    at sun.reflect.GeneratedMethodAccessor1341.invoke(Unknown Source)

    I also see 

    [JaCoCo plugin] Loading packageyys..
    Exception in thread "jenkins.util.Timer [#4]" java.lang.OutOfMemoryError: GC overhead limit exceeded
    May 25, 2016 11:00:06 AM org.eclipse.jetty.util.log.JavaUtilLog warn

    in the jenkins.log

  5. What is the configuration change to get the graph lines for "instructions", "branch", "complexity", "method" and "class" coverage?

    Currently I am getting the charts for the lines only. I do have stats gathered for the other aspects as well.

  6. Need immediate help

    I am using 0.7.6 [jacoco plugin] for gradle local jacoco build - sucessfully able to generate reports, Using 1.0.19[jacoco plugin] for jenkins reports are generated but results for [gradle reports] and [jenkins reports] are different please help it would be a great help!!!

  7. Had to add a line defining the sonar.jacoco.reportPaths property.

  8. Please help!

    Does 2.0.0[jacoco plugin] compatible with Jenkins core 1.580.1? 

    1. The parent-version in the pom mostly controls which version of the Jenkins server should still work, for 2.0.0 we have <version>1.424.6</version>, for latest version we have <version>1.614</version>, so for 2.0.0 version of the plugin it should still work, for newer versions it probably requires an update of the Jenkins server, although I am not 100% sure if the version-dependencies are enforced or just "guidelines".

      1. Thank you! This is really helpful!

      2. Thank you! This is really helpful!

  9. Hello. Please help!

    The JaCoCo plugin does not find any files if I simply put **/**.exec in the "Path to exec files" field. I am using JaCoCo version 0.8.0 with JaCoCo Jenkins plugin version 2.2.1.

    Before the JaCoCo plugin step, I have the files moved to outside of the build workspace, but when I try to provide an absolute path to the files, I get "Expecting Ant GLOB pattern, but saw '/xx/yy/zz/**/**.exec'."

    I also tried putting "../../<path>/**/**.exec, but that also was unable to find any files.

    Is it possible to use this plugin with files that aren't in the build workspace? If so, how?

    Thanks!

     

  10. In the Emma plugin, I could specify the location of my coverage.xml file. How do I do that with JaCoCo? 

    1. I would use the Emma plugin, but it doesn't support pipelines

      1. See "path to exec file", there you can specify where *.exec files are found after your build was executed.

        1. I tried passing my coverage.xml file, but it said java.io.IOException: Invalid execution data file.

          1. JaCoCo works with a binary file with ending .exec, not an XML file.

            1. VsTest creates binary coverage file with a {{.coverage}} extension, but that also gave me

              java.io.IOException: Invalid execution data file. 
  11. Hi,

    Are Jacoco coverage deltas compared to only merged code or also to new code?

    My Jenkins job calculated jacoco code coverage on not submitted code. The current job deltas coverage is calculated compared to the last successful build. The last successful build code is not merged yet. Is the calculation done on merged code or also on new not merged code?

    Regards,

    Hadas

Write a comment…