Jacoco.exec file shows 0% coverage when used with jenkins matrix project plugin. Jacoco HTML reports display correct results

3,317 views
Skip to first unread message

sahana tambi

unread,
Mar 4, 2016, 7:34:30 PM3/4/16
to Jenkins JaCoCo plugin mailing list
I am using the following script for jacoco code coverage. HTML reports display correct results for junit test cases, where as the exec file shows 0% coverage. I am using JUnit testing, and my Unit tests are located at app/src/test/. I am trying to use this jacoco.exec in jacoco jenkins plugin to display my results. My jenkins is setup using amtrix project plugin. What am I doing wrong? My jenkins version is 1.596.2. 

I appreciate any inputs on this one.

apply plugin: 'jacoco'

jacoco {
    toolVersion = "0.7.5.201505241946"
}

project.afterEvaluate {
    // Grab all build types and product flavors
    def buildTypes = android.buildTypes.collect { type -> type.name }
    def productFlavors = android.productFlavors.collect { flavor -> flavor.name }

    // When no product flavors defined, use empty
    if (!productFlavors) productFlavors.add('')

    productFlavors.each { productFlavorName ->
        buildTypes.each { buildTypeName ->
            def sourceName, sourcePath
            if (!productFlavorName) {
                sourceName = sourcePath = "${buildTypeName}"
            } else {
                sourceName = "${productFlavorName}${buildTypeName.capitalize()}"
                sourcePath = "${productFlavorName}/${buildTypeName}"
            }
            def testTaskName = "test${sourceName.capitalize()}UnitTest"

            // Create coverage task of form 'testFlavorTypeCoverage' depending on 'testFlavorTypeUnitTest'
            task "${testTaskName}Coverage" (type:JacocoReport, dependsOn: "$testTaskName") {
                group = "Reporting"
                description = "Generate Jacoco coverage reports on the ${sourceName.capitalize()} build."

                classDirectories = fileTree(
                        dir: "${project.buildDir}/intermediates/classes/${sourcePath}",
                        excludes: ['**/R.class',
                                   '**/R$*.class',
                                   '**/*$ViewInjector*.*',
                                   '**/*$ViewBinder*.*',
                                   '**/BuildConfig.*',
                                   '**/Manifest*.*']
                )

                def coverageSourceDirs = [
                        "src/main/java",
                        "src/$productFlavorName/java",
                        "src/$buildTypeName/java"
                ]
                additionalSourceDirs = files(coverageSourceDirs)
                sourceDirectories = files(coverageSourceDirs)
                executionData = files("${project.buildDir}/jacoco/${testTaskName}.exec")

                reports {
                    xml.enabled = true
                    html.enabled = true
html.destination = "${System.getenv('View_Root')}/_Build/Jacoco"
                }
            }
        }
    }
}

-Sahana T

Dominik Stadler

unread,
Mar 5, 2016, 2:56:15 AM3/5/16
to jenkins-jacoco-pl...@googlegroups.com

What version of the jacoco-plugin are you using? Please try with 2.0.0 or newer.

Thanks... Dominik

--
Azért kapta ezt az üzenetet, mert feliratkozott a Google Csoportok „Jenkins JaCoCo plugin mailing list” csoportjára.
Az erről a csoportról és az ahhoz kapcsolódó e-mailekről való leiratkozáshoz küldjön egy e-amailt a(z) jenkins-jacoco-plugin-m...@googlegroups.com címre.
Ha üzenetet szeretne küldeni ebbe a csoportba, küldjön e-mailt a(z) jenkins-jacoco-pl...@googlegroups.com címre.
További lehetőségekért látogasson el ide: https://groups.google.com/d/optout.

sahana tambi

unread,
Mar 7, 2016, 2:36:07 PM3/7/16
to Jenkins JaCoCo plugin mailing list
Yes, I am using 2.0.1 version. But no luck, how do I open an exec other than jenkins. So that i know that jenkins jacoco plugin is the issue and not jacoco code coverage itself.
Az erről a csoportról és az ahhoz kapcsolódó e-mailekről való leiratkozáshoz küldjön egy e-amailt a(z) jenkins-jacoco-plugin-mailing-list+unsubscribe@googlegroups.com címre.
Ha üzenetet szeretne küldeni ebbe a csoportba, küldjön e-mailt a(z) jenkins-jacoco-plugin-mailing-li...@googlegroups.com címre.

Dominik Stadler

unread,
Mar 7, 2016, 3:02:00 PM3/7/16
to jenkins-jacoco-pl...@googlegroups.com
If the HTML report from the project itself looks good then JaCoCo seems to work.

Can you paste the output of the JaCoCo-plugin from the Jenkins Job Console output? Maybe something in there shows why it happens for you.

Thanks... Dominik.

Az erről a csoportról és az ahhoz kapcsolódó e-mailekről való leiratkozáshoz küldjön egy e-amailt a(z) jenkins-jacoco-plugin-m...@googlegroups.com címre.
Ha üzenetet szeretne küldeni ebbe a csoportba, küldjön e-mailt a(z) jenkins-jacoco-pl...@googlegroups.com címre.

További lehetőségekért látogasson el ide: https://groups.google.com/d/optout.

--
Azért kapta ezt az üzenetet, mert feliratkozott a Google Csoportok „Jenkins JaCoCo plugin mailing list” csoportjára.
Az erről a csoportról és az ahhoz kapcsolódó e-mailekről való leiratkozáshoz küldjön egy e-amailt a(z) jenkins-jacoco-plugin-m...@googlegroups.com címre.
Ha üzenetet szeretne küldeni ebbe a csoportba, küldjön e-mailt a(z) jenkins-jacoco-pl...@googlegroups.com címre.

sahana tambi

unread,
Mar 7, 2016, 3:46:37 PM3/7/16
to jenkins-jacoco-pl...@googlegroups.com
This is what I see when I run the command for code coverage. 

C:\Workspace\TestApplication>gradlew testDemoDebugUnitTestCoverage
:app:preBuild UP-TO-DATE
:app:preDemoDebugBuild UP-TO-DATE
:app:checkDemoDebugManifest
:app:prepareDemoDebugDependencies
:app:compileDemoDebugAidl UP-TO-DATE
:app:compileDemoDebugRenderscript UP-TO-DATE
:app:generateDemoDebugBuildConfig UP-TO-DATE
:app:generateDemoDebugAssets UP-TO-DATE
:app:mergeDemoDebugAssets UP-TO-DATE
:app:generateDemoDebugResValues UP-TO-DATE
:app:generateDemoDebugResources UP-TO-DATE
:app:mergeDemoDebugResources UP-TO-DATE
:app:processDemoDebugManifest UP-TO-DATE
:app:processDemoDebugResources UP-TO-DATE
:app:generateDemoDebugSources UP-TO-DATE
:app:compileDemoDebugJavaWithJavac
:app:preDemoDebugUnitTestBuild UP-TO-DATE
:app:prepareDemoDebugUnitTestDependencies
:app:compileDemoDebugUnitTestJavaWithJavac
:app:processDemoDebugJavaRes UP-TO-DATE
:app:processDemoDebugUnitTestJavaRes UP-TO-DATE
:app:compileDemoDebugUnitTestSources
:app:mockableAndroidJar
:app:assembleDemoDebugUnitTest
:app:testDemoDebugUnitTest
:app:testDemoDebugUnitTestCoverage

BUILD SUCCESSFUL

Thanks,
Sahana

Azért kapta ezt az üzenetet, mert feliratkozott a Google Csoportok „Jenkins JaCoCo plugin mailing list” témájára.
A témáról való leiratkozáshoz látogasson el a következő címre: https://groups.google.com/d/topic/jenkins-jacoco-plugin-mailing-list/E-vJvRNuVM0/unsubscribe.
Az erről a csoportról és minden témájáról való leiratkozáshoz küldjön egy levelet a következő címre: jenkins-jacoco-plugin-m...@googlegroups.com.

Dominik Stadler

unread,
Mar 7, 2016, 4:54:57 PM3/7/16
to jenkins-jacoco-pl...@googlegroups.com
Hi,

I rather meant the output of the JaCoCo-plugin in Jenkins. The Gradle-build-output does not show much that will help for this question...

Dominik.

sahana tambi

unread,
Mar 7, 2016, 6:09:15 PM3/7/16
to jenkins-jacoco-pl...@googlegroups.com
Run condition [Regular expression match] enabling perform for step [[Publish HTML reports]]
[htmlpublisher] Archiving HTML reports...
[htmlpublisher] Archiving at PROJECT level /Jenkins/workspace/Sandbox_Build/Build_Targets/Android_ARM/_Build/Jacoco to /data/jenkins/jobs/Sandbox_Build/configurations/axis-Build_Targets/Android_ARM/htmlreports/Jacoco_Code_Coverage
Regular expression run condition: Expression=[Android_ARM], Label=[Android_ARM]
Run condition [Regular expression match] enabling perform for step [[Record JaCoCo coverage report]]
[JaCoCo plugin] Collecting JaCoCo coverage data...
[JaCoCo plugin] **/build/jacoco/*.exec;**/build/intermediates/classes;**/src/main/java; locations are configured
[JaCoCo plugin] Number of found exec files for pattern **/build/jacoco/*.exec: 4
[JaCoCo plugin] Saving matched execfiles:  /Jenkins/workspace/Sandbox_Build/Build_Targets/TestApplication/app/build/jacoco/testDemoDebugUnitTest.exec /Jenkins/workspace/Sandbox_Build/Build_Targets/TestApplication/app/build/jacoco/testDemoReleaseUnitTest.exec /Jenkins/workspace/Sandbox_Build/Build_Targets/TestApplication/app/build/jacoco/testFullDebugUnitTest.exec /Jenkins/workspace/Sandbox_Build/Build_Targets/TestApplication/app/build/jacoco/testFullReleaseUnitTest.exec
[JaCoCo plugin] Saving matched class directories for class-pattern: **/build/intermediates/classes: /Jenkins/workspace/Sandbox_Build/Build_Targets/TestApplication/app/build/intermediates/classes
[JaCoCo plugin] Saving matched source directories for source-pattern: **/src/main/java: /Jenkins/workspace/Sandbox_Build/Build_Targets/Android/APILevel17/BLETestApp/app/src/main/java /Jenkins/workspace/Sandbox_Build/Build_Targets/TestApplication/app/src/main/java
[JaCoCo plugin] Loading inclusions files.. [JaCoCo plugin] inclusions: [] [JaCoCo plugin] exclusions: [**/R.class, **/R$*.class, **/*$ViewInjector*.*, **/*$ViewBinder*.*, **/BuildConfig.*, **/Manifest*.*] [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. Run condition [Always] enabling perform for step [[Delete workspace when build is done]] Deleting project workspace... done Notifying upstream projects of job completion Finished: SUCCESS

Dominik Stadler

unread,
Mar 8, 2016, 8:48:26 AM3/8/16
to jenkins-jacoco-pl...@googlegroups.com
Hmm,

that looks fine on a quick look, not sure why you end with no results, looks a bit like the .exec files are from runs where no actual tests were executed and thus code-coverage is actually 0?

Dominik.

Dominik Stadler

unread,
Mar 8, 2016, 9:25:14 AM3/8/16
to jenkins-jacoco-pl...@googlegroups.com
Hi,

I did a second look and it seems you are not using the latest version of the JaCoCo-plugin after all. With an up-to-date plugin version there would be a line "[JaCoCo plugin] Overall coverage: ..." in the output which would show the numbers that are found. Missing this means that you likely actually run a plugin-version below 2.0.0 which can not work with JaCoCo 0.7.5 or newer.

Dominik.

sahana tambi

unread,
Mar 8, 2016, 4:05:41 PM3/8/16
to jenkins-jacoco-pl...@googlegroups.com
That's a good catch! How do I verify the plugin version on Jenkins? How do I use latest jacoco plugin in jenkins? Or is it required for me to user older version of Jacoco than 0.7.5? If so which version of jacoco should I use?

Dominik Stadler

unread,
Mar 9, 2016, 3:08:21 AM3/9/16
to jenkins-jacoco-pl...@googlegroups.com
The "Manage Jenkins -> Manage Plugins" shows the plugin versions, you need to manually upgrade plugins, they are not updated automatically.

If you cannot update the plugin and really need to downgrade JaCoCo, then use 0.7.4.

Dominik.

sahana tambi

unread,
Mar 15, 2016, 1:44:18 PM3/15/16
to jenkins-jacoco-pl...@googlegroups.com
Thanks a lot Dominik! I am able to get the reports working with Jacoco plugin. Upgradig the plugin version fixed my problem.

Sai Madhavan

unread,
Jul 24, 2017, 4:36:34 PM7/24/17
to Jenkins JaCoCo plugin mailing list
Dominik, I'm not sure if you are still monitoring this thread.

I had a follow up question. Does the latest Jenkins Jacoco plugin understand both the old and new formats generated by different versions of jacoco?

- Sai
Az erről a csoportról és az ahhoz kapcsolódó e-mailekről való leiratkozáshoz küldjön egy e-amailt a(z) jenkins-jacoco-plugin-mailing-list+unsubscribe@googlegroups.com címre.
Ha üzenetet szeretne küldeni ebbe a csoportba, küldjön e-mailt a(z) jenkins-jacoco-plugin-mailing-li...@googlegroups.com címre.

További lehetőségekért látogasson el ide: https://groups.google.com/d/optout.

--
Azért kapta ezt az üzenetet, mert feliratkozott a Google Csoportok „Jenkins JaCoCo plugin mailing list” csoportjára.
Az erről a csoportról és az ahhoz kapcsolódó e-mailekről való leiratkozáshoz küldjön egy e-amailt a(z) jenkins-jacoco-plugin-mailing-list+unsubscribe@googlegroups.com címre.
Ha üzenetet szeretne küldeni ebbe a csoportba, küldjön e-mailt a(z) jenkins-jacoco-plugin-mailing-li...@googlegroups.com címre.

További lehetőségekért látogasson el ide: https://groups.google.com/d/optout.

--
Azért kapta ezt az üzenetet, mert feliratkozott a Google Csoportok „Jenkins JaCoCo plugin mailing list” témájára.
A témáról való leiratkozáshoz látogasson el a következő címre: https://groups.google.com/d/topic/jenkins-jacoco-plugin-mailing-list/E-vJvRNuVM0/unsubscribe.
Az erről a csoportról és minden témájáról való leiratkozáshoz küldjön egy levelet a következő címre: jenkins-jacoco-plugin-mailing-list+unsubscribe@googlegroups.com.
Ha üzenetet szeretne küldeni ebbe a csoportba, küldjön e-mailt a(z) jenkins-jacoco-plugin-mailing-li...@googlegroups.com címre.

További lehetőségekért látogasson el ide: https://groups.google.com/d/optout.

--
Azért kapta ezt az üzenetet, mert feliratkozott a Google Csoportok „Jenkins JaCoCo plugin mailing list” csoportjára.
Az erről a csoportról és az ahhoz kapcsolódó e-mailekről való leiratkozáshoz küldjön egy e-amailt a(z) jenkins-jacoco-plugin-mailing-list+unsubscribe@googlegroups.com címre.
Ha üzenetet szeretne küldeni ebbe a csoportba, küldjön e-mailt a(z) jenkins-jacoco-plugin-mailing-li...@googlegroups.com címre.

További lehetőségekért látogasson el ide: https://groups.google.com/d/optout.

--
Azért kapta ezt az üzenetet, mert feliratkozott a Google Csoportok „Jenkins JaCoCo plugin mailing list” témájára.
A témáról való leiratkozáshoz látogasson el a következő címre: https://groups.google.com/d/topic/jenkins-jacoco-plugin-mailing-list/E-vJvRNuVM0/unsubscribe.
Az erről a csoportról és minden témájáról való leiratkozáshoz küldjön egy levelet a következő címre: jenkins-jacoco-plugin-mailing-list+unsubscribe@googlegroups.com.
Ha üzenetet szeretne küldeni ebbe a csoportba, küldjön e-mailt a(z) jenkins-jacoco-plugin-mailing-li...@googlegroups.com címre.

További lehetőségekért látogasson el ide: https://groups.google.com/d/optout.

--
Azért kapta ezt az üzenetet, mert feliratkozott a Google Csoportok „Jenkins JaCoCo plugin mailing list” csoportjára.
Az erről a csoportról és az ahhoz kapcsolódó e-mailekről való leiratkozáshoz küldjön egy e-amailt a(z) jenkins-jacoco-plugin-mailing-list+unsubscribe@googlegroups.com címre.
Ha üzenetet szeretne küldeni ebbe a csoportba, küldjön e-mailt a(z) jenkins-jacoco-plugin-mailing-li...@googlegroups.com címre.

További lehetőségekért látogasson el ide: https://groups.google.com/d/optout.

--
Azért kapta ezt az üzenetet, mert feliratkozott a Google Csoportok „Jenkins JaCoCo plugin mailing list” témájára.
A témáról való leiratkozáshoz látogasson el a következő címre: https://groups.google.com/d/topic/jenkins-jacoco-plugin-mailing-list/E-vJvRNuVM0/unsubscribe.
Az erről a csoportról és minden témájáról való leiratkozáshoz küldjön egy levelet a következő címre: jenkins-jacoco-plugin-mailing-list+unsubscribe@googlegroups.com.
Ha üzenetet szeretne küldeni ebbe a csoportba, küldjön e-mailt a(z) jenkins-jacoco-plugin-mailing-li...@googlegroups.com címre.

További lehetőségekért látogasson el ide: https://groups.google.com/d/optout.

--
Azért kapta ezt az üzenetet, mert feliratkozott a Google Csoportok „Jenkins JaCoCo plugin mailing list” csoportjára.
Az erről a csoportról és az ahhoz kapcsolódó e-mailekről való leiratkozáshoz küldjön egy e-amailt a(z) jenkins-jacoco-plugin-mailing-list+unsubscribe@googlegroups.com címre.
Ha üzenetet szeretne küldeni ebbe a csoportba, küldjön e-mailt a(z) jenkins-jacoco-plugin-mailing-li...@googlegroups.com címre.

További lehetőségekért látogasson el ide: https://groups.google.com/d/optout.

--
Azért kapta ezt az üzenetet, mert feliratkozott a Google Csoportok „Jenkins JaCoCo plugin mailing list” témájára.
A témáról való leiratkozáshoz látogasson el a következő címre: https://groups.google.com/d/topic/jenkins-jacoco-plugin-mailing-list/E-vJvRNuVM0/unsubscribe.
Az erről a csoportról és minden témájáról való leiratkozáshoz küldjön egy levelet a következő címre: jenkins-jacoco-plugin-mailing-list+unsubscribe@googlegroups.com.
Ha üzenetet szeretne küldeni ebbe a csoportba, küldjön e-mailt a(z) jenkins-jacoco-plugin-mailing-li...@googlegroups.com címre.

Dominik Stadler

unread,
Jul 26, 2017, 4:45:26 PM7/26/17
to jenkins-jacoco-pl...@googlegroups.com
Hi,

the current latest version of the plugin only understands the newer format, there were some discussions and a PR (https://github.com/jenkinsci/jacoco-plugin/pull/82) where support for the old format was added, but I am still reluctant to merge this into the mainline as only few people actually require something like this and it would add a large amount of complexity.

You can check out the PR, build it locally and import the resulting .hpi file manually in the Jenkins plugin management pages to try the proposed changes on your system.

Dominik.

Esdras Neto

unread,
Sep 27, 2017, 11:04:34 AM9/27/17
to Jenkins JaCoCo plugin mailing list
Good afternoon,

I have this issue as well, however my Jacoco version is 0.7.9 and I am using the latest plugin 2.2.1.

The html reports are showing fine, would appreciate any help :-)

Thanks!
Esdras 

Sandra Perez

unread,
Sep 29, 2017, 7:05:07 AM9/29/17
to Jenkins JaCoCo plugin mailing list
Hi Esdras,

Any luck with this issue? it's happening the same to me, html report is generated fine but when I tried to generate the jenkins report coverage is always 0.

I would really appreciate any help on this.

Thank you!

Esdras Neto

unread,
Sep 29, 2017, 11:18:33 AM9/29/17
to Jenkins JaCoCo plugin mailing list
Did not manage to figure out yet... I tried using different versions of the jacoco plugin but looks like the old ones don't support pipelines.
Reply all
Reply to author
Forward
0 new messages