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

JacocoPublisher (part of pipeline-maven) does not deal with excludes properly

    • 1381.v08b_63fa_30559

      The jacoco report published by pipeline indicates classes that should have been excluded.

       

      Our build, a multi-module maven build executes jacoco on multiple modules.  In the POM, we indicate <exclude> on a number of classes (generated java).  When built by maven (command-line), the jacoco report is properly created - excluded files are properly excluded.  When we wrapper this build into a jenkinsfile and invoke it via a withMaven(..), the JacocoPublisher kicks in.  The jacoco report on the Jenkins job appears to include the excluded files.  It looks to me like JacocoPublisher is reinvoking Jacoco-Plugin with default parameters. The Jacoco-Plugin output shows a blank line for 'exclude', which explains why the report has things it should not.

      I suspect the easiest solution is to offer a parameter on JacocoPubisher that would pass-through to the Jacoco-Plugin.  This would allow people to write Jenkinsfiles, enter the 'excludes' they desire, and Jacoco-Plugin would then run properly.

          [JENKINS-59813] JacocoPublisher (part of pipeline-maven) does not deal with excludes properly

          Found a work-around of sorts.   Completely disable the JacocoPublisher and use the external 'jacoco' step instead.  Since the latter accepts exclude, it can be properly configured.  If you don't disable the JacocoPublisher, you wind up with two similar looking reports in Jenkins.

          Jeffrey Bennett added a comment - Found a work-around of sorts.   Completely disable the JacocoPublisher and use the external 'jacoco' step instead.  Since the latter accepts exclude, it can be properly configured.  If you don't disable the JacocoPublisher, you wind up with two similar looking reports in Jenkins.

          Cyrille Le Clerc added a comment - Work In Progress: JacocoPublisher settings only support a `disabled` flag. See  https://github.com/jenkinsci/pipeline-maven-plugin/blob/pipeline-maven-3.8.2/jenkins-plugin/src/main/java/org/jenkinsci/plugins/pipeline/maven/publishers/JacocoReportPublisher.java#L254  

          Jeff Thomas added a comment -

          Any Updates? 

          Same here:

          Jacoco Publisher options set in 'withMaven' options but totally ignored by the jacocoPublisher.{}

          stage('packaging and testing') {
            steps {
              withMaven(
                maven: 'maven',
                mavenSettingsConfig: "${MAVEN_SETTINGS}",
                options: [
                  ...,
                  jacocoPublisher(exclusionPattern: '**/DTO.class', sourceExclusionPattern: '*/*DTO.java')]
              ) {
                sh "mvn verify -U"
          {{    }}}
          {{  }}}
          }

           

          Jeff Thomas added a comment - Any Updates?  Same here: Jacoco Publisher options set in 'withMaven' options but totally ignored by the jacocoPublisher.{ } stage('packaging and testing') {   steps {     withMaven(       maven: 'maven',       mavenSettingsConfig: "${MAVEN_SETTINGS}",       options: [         ...,         jacocoPublisher(exclusionPattern: '**/ DTO.class', sourceExclusionPattern: ' */*DTO.java')]     ) {       sh "mvn verify -U" {{    }}} {{  }}} }  

          Eric Norman added a comment -

          I also encountered this problem in one of my projects and have attempted to provide a solution in the github PR #764

          Please review and merge if you agree with the solution.

          Eric Norman added a comment - I also encountered this problem in one of my projects and have attempted to provide a solution in the github PR #764 Please review and merge if you agree with the solution.

            bguerin Benoit
            jbennett20912 Jeffrey Bennett
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: