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

Jenkins Jacoco plugin not including sources from other projects in workspace


    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • jacoco-plugin
    • None
    • Windows 10. JDK zulu8.64.0.19-ca-fx-jdk8.0.345-win_x64

      I have an issue with Jenkins Jacoco plugin. It is not picking up the Java sources from other projects in the workspace. Because of this the coverage reports do not show the correct coverage information. It basically shows that none of the code has been covered by the test cases.

      Here's my setup

      • lib: all project lib jars are present here
      • ProjectTest; contains Junit test cases. Depends on jars present in the lib folder.
      • ProjectA: contains sources that are built and jar copied to lib
      • ProjectB: contains sources that are built and jar copied to lib
      • ProjectC: contains sources that are built and jar copied to lib

      My Jenkins pipline has this:
      post {

      {             junit allowEmptyResults: true, keepLongStdio: true, skipPublishingChecks: true, testResults: 'Projects/ProjectTest/reports/junit/*.xml'             publishCoverage adapters: [jacocoAdapter(mergeToOneReport: true, path:'Projects/ProjectTest/reports/jacoco/*.xml')]             jacoco execPattern: '**/build/**.exec', sourceInclusionPattern: '**/*.java', sourcePattern: '**/src'         }

      Everything runs fine and coverage report are generated. However, only the sources present in the ProjectTest show coverage details. Sources from ProjectA, ProjectB and ProjectC dont show any any coverage.

      Jenkins output shows:
      [JaCoCo plugin] Saving matched source directories for source-pattern: **/src: 
      [JaCoCo plugin] Source Inclusions: */.java
      [JaCoCo plugin] Source Exclusions: 
      [JaCoCo plugin] - c:\Projects\ProjectA\src 9 files
      [JaCoCo plugin] - c:\Projects\ProjectB\src 7 files
      [JaCoCo plugin] - c:\Projects\ProjectC\src 147 files

      For some reason Jacoco has exlcudes all source of my projects in the workspace.

      1. Why is Jenkins/Jacoco automatically excluding my project sources?
      2. Is it possible to add those projects sources? If yes then how? I have tried various combinations such as: jacoco execPattern: '*/build/.exec', sourceInclusionPattern: './ProjectA,ProjectB//.java,*/.java', sourcePattern: '**/src', but nothing works.

      Please help.


            ognjenb Ognjen Bubalo
            binfer Bobby Moin
            0 Vote for this issue
            1 Start watching this issue