Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-15570

Coverage report includes classes that have been excluded from Jacoco analysis

      In my Maven config there are a number of classes that are excluded from Jacoco analysis. The report generated by Jacoco does not include these classes. The report generated by the Jenkins Jacoco plugin does includes these classes which gives a misleading picture and makes it difficult to set any coverage thresholds. I think this may be related to JENKINS-14975.

          [JENKINS-15570] Coverage report includes classes that have been excluded from Jacoco analysis

          René Scheibe added a comment -

          A workaround is to configure the exclusions in the Jenkins Jacoco-Plugin too.

          René Scheibe added a comment - A workaround is to configure the exclusions in the Jenkins Jacoco-Plugin too.

          Jae Gangemi added a comment -

          is there any futher movement on this issue? configuring exclusions in maven and jenkins is not a viable work around.

          Jae Gangemi added a comment - is there any futher movement on this issue? configuring exclusions in maven and jenkins is not a viable work around.

          Alex Taylor added a comment -

          I was looking into this issue and it appears that the Jacoco plugin fixed this issue for ENV variables with https://github.com/jenkinsci/jacoco-plugin/pull/74 but it does not actually parse the pom.xml for the `excludes`(or `includes` for that matter) configuration. Does that sound like the actual issue here rather than the Excludes not working at all?

           

          Did I miss anything here? I was going to work on getting this fixed with a PR hopefully within the next week

          Alex Taylor added a comment - I was looking into this issue and it appears that the Jacoco plugin fixed this issue for ENV variables with https://github.com/jenkinsci/jacoco-plugin/pull/74  but it does not actually parse the pom.xml for the `excludes`(or `includes` for that matter) configuration. Does that sound like the actual issue here rather than the Excludes not working at all?   Did I miss anything here? I was going to work on getting this fixed with a PR hopefully within the next week

          Jae Gangemi added a comment -

          i'm confused as to why this information just isn't part of the generated results file in the first place as a block that indicates what to exclude. perhaps even better would just be excluding the classes from the result file outright. disclaimer: i have not looked into how the maven plugin works when i choose to generate a report, but it does do the proper exclusions.

          if the plugin needs to parse the pom to figure this out, then that is the fix but that doesn't really seem like the correct solution here b/c what if i'm a nodejs project that is able to generate coverage reports in jacoco format? there's not going to be any pom to parse for exclusions in that case.

          Jae Gangemi added a comment - i'm confused as to why this information just isn't part of the generated results file in the first place as a block that indicates what to exclude. perhaps even better would just be excluding the classes from the result file outright. disclaimer: i have not looked into how the maven plugin works when i choose to generate a report, but it does do the proper exclusions. if the plugin needs to parse the pom to figure this out, then that is the fix but that doesn't really seem like the correct solution here b/c what if i'm a nodejs project that is able to generate coverage reports in jacoco format? there's not going to be any pom to parse for exclusions in that case.

          ataylor , what you've described, regarding the exclude block in the maven plugin not taking affect in Jenkins, is the issue I've seen and am interested in a fix for, and seems to align with the initial description (which is specific to maven based projects).

          Gabriel Stanek added a comment - ataylor , what you've described, regarding the exclude block in the maven plugin not taking affect in Jenkins, is the issue I've seen and am interested in a fix for, and seems to align with the initial description (which is specific to maven based projects).

          Alex Taylor added a comment -

          Thanks for the update gstanek just wanted make sure I was understanding everyone's issue and how best I can fix it

          Alex Taylor added a comment - Thanks for the update gstanek just wanted make sure I was understanding everyone's issue and how best I can fix it

          really looking forward to this fix! lots of anxiety around this bug

          Alan Czajkowski added a comment - really looking forward to this fix! lots of anxiety around this bug

          Rajiv Jandial added a comment -

          I am still seeing this as an open issue. Even I exclude the package from the pom.xml as well as from the Jenkins "exclusions" fields, those packages are still being included in the JaCoCo report.

          Rajiv Jandial added a comment - I am still seeing this as an open issue. Even I exclude the package from the pom.xml as well as from the Jenkins "exclusions" fields, those packages are still being included in the JaCoCo report.

          Pablo Grisafi added a comment -

          my workaround: in the pom.xml I save all patterns  as properties:

          <coverage-exclusion-01>*/com/company/product//config//.</coverage-exclusion-01><coverage-exclusion-02>/com/company/cfa//CallDTO.</coverage-exclusion-02><coverage-exclusion-03>*/com/company/cfa/*/DAO.</coverage-exclusion-03>

          And I use them to configure the maven jacoco plugin

          <configuration> <excludes> <exclude>${coverage-exclusion-01}</exclude> <exclude>${coverage-exclusion-02}</exclude>

          etc...

           

          And then, in the pipeline file y read again the properties

           

          script{      props = readMavenPom().getProperties()     exclusionPattern = props.entrySet().findAll\{entry -> entry.key.startsWith('coverage-exclusion-')}.collect{it.value}.join(',')
              echo "exclusionPattern = ${exclusionPattern}"
          }
          jacoco( execPattern: '**/target/jacoco.exec', exclusionPattern: exclusionPattern)

           

          It works, but is ugly

           

           

          Pablo Grisafi added a comment - my workaround: in the pom.xml I save all patterns  as properties: < coverage-exclusion-01 > * /com/company/product/ /config/ / . </ coverage-exclusion-01 > < coverage-exclusion-02 > /com/company/cfa/ /CallDTO. </ coverage-exclusion-02 > < coverage-exclusion-03 > * /com/company/cfa/ */ DAO. </ coverage-exclusion-03 > And I use them to configure the maven jacoco plugin < configuration > < excludes > < exclude > ${coverage-exclusion-01} </ exclude > < exclude > ${coverage-exclusion-02} </ exclude > etc...   And then, in the pipeline file y read again the properties   script{      props = readMavenPom().getProperties()     exclusionPattern = props.entrySet().findAll\{entry -> entry.key.startsWith('coverage-exclusion-')}.collect{it.value}.join(',')     echo "exclusionPattern = ${exclusionPattern}" } jacoco( execPattern: '**/target/jacoco.exec', exclusionPattern: exclusionPattern)   It works, but is ugly    

          Ariel M added a comment -

          We are also facing the same issue. it's weird coz' it's working for one MS, but not for the other. is there any update for it?

          Ariel M added a comment - We are also facing the same issue. it's weird coz' it's working for one MS, but not for the other. is there any update for it?

            ognjenb Ognjen Bubalo
            daknin Darrell King
            Votes:
            23 Vote for this issue
            Watchers:
            29 Start watching this issue

              Created:
              Updated: