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

Confusing failure mode when no classes found by classPattern

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • jacoco-plugin
    • None

      If the classPattern fails to match any classes, the builds/*/jacoco/classes directory is never created, causing an exception later in the report generating stage. This is confusing. It should either generate an empty report or fail immediately and with a clear message when no classes were found.

          [JENKINS-19916] Confusing failure mode when no classes found by classPattern

          Markus Schlegel added a comment - - edited

          I assume, I have the same problem here. I get the error:

          ...
          BUILD SUCCESSFUL
          Total time: 25 minutes 35 seconds
          Archiving artifacts
          Recording test results
          [JaCoCo plugin] Collecting JaCoCo coverage data...
          [JaCoCo plugin] antbuild/test-reports/*.exec;antbuild/all;source/java/**; locations are configured
          [JaCoCo plugin] Number of found exec files: 0
          [JaCoCo plugin] Saving matched execfiles:  
          [JaCoCo plugin] Saving matched class directories: 
          [JaCoCo plugin] Saving matched source directories: 
          [JaCoCo plugin] Loading inclusions files..
          [JaCoCo plugin] inclusions: []
          [JaCoCo plugin] exclusions: [**/*Test*.class]
          ERROR: Publisher hudson.plugins.jacoco.JacocoPublisher aborted due to exception
          java.lang.IllegalStateException: basedir C:\Jenkins\jobs\Trunk_TestCoverage\builds\2014-10-01_09-16-20\jacoco\classes does not exist
          	at org.codehaus.plexus.util.DirectoryScanner.scan(DirectoryScanner.java:550)
          	at org.codehaus.plexus.util.FileUtils.getFileAndDirectoryNames(FileUtils.java:1717)
          	at org.codehaus.plexus.util.FileUtils.getFileNames(FileUtils.java:1645)
          	at org.codehaus.plexus.util.FileUtils.getFileNames(FileUtils.java:1627)
          	at org.codehaus.plexus.util.FileUtils.getFiles(FileUtils.java:1601)
          	at org.codehaus.plexus.util.FileUtils.getFiles(FileUtils.java:1584)
          	at hudson.plugins.jacoco.ExecutionFileLoader.analyzeStructure(ExecutionFileLoader.java:128)
          	at hudson.plugins.jacoco.ExecutionFileLoader.loadBundleCoverage(ExecutionFileLoader.java:137)
          	at hudson.plugins.jacoco.JacocoReportDir.parse(JacocoReportDir.java:102)
          	at hudson.plugins.jacoco.JacocoBuildAction.loadRatios(JacocoBuildAction.java:291)
          	at hudson.plugins.jacoco.JacocoBuildAction.load(JacocoBuildAction.java:273)
          	at hudson.plugins.jacoco.JacocoPublisher.perform(JacocoPublisher.java:371)
          	at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
          	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:770)
          	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:734)
          	at hudson.model.Build$BuildExecution.post2(Build.java:183)
          	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:683)
          	at hudson.model.Run.execute(Run.java:1770)
          	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
          	at hudson.model.ResourceController.execute(ResourceController.java:89)
          	at hudson.model.Executor.run(Executor.java:240)
          

          after the build was otherwise successful.
          I am using the enhanced project's settings to reuse the workspace of a our main job. Maybe this is related to this kind of setup?

          Markus Schlegel added a comment - - edited I assume, I have the same problem here. I get the error: ... BUILD SUCCESSFUL Total time: 25 minutes 35 seconds Archiving artifacts Recording test results [JaCoCo plugin] Collecting JaCoCo coverage data... [JaCoCo plugin] antbuild/test-reports/*.exec;antbuild/all;source/java/**; locations are configured [JaCoCo plugin] Number of found exec files: 0 [JaCoCo plugin] Saving matched execfiles: [JaCoCo plugin] Saving matched class directories: [JaCoCo plugin] Saving matched source directories: [JaCoCo plugin] Loading inclusions files.. [JaCoCo plugin] inclusions: [] [JaCoCo plugin] exclusions: [**/*Test*.class] ERROR: Publisher hudson.plugins.jacoco.JacocoPublisher aborted due to exception java.lang.IllegalStateException: basedir C:\Jenkins\jobs\Trunk_TestCoverage\builds\2014-10-01_09-16-20\jacoco\classes does not exist at org.codehaus.plexus.util.DirectoryScanner.scan(DirectoryScanner.java:550) at org.codehaus.plexus.util.FileUtils.getFileAndDirectoryNames(FileUtils.java:1717) at org.codehaus.plexus.util.FileUtils.getFileNames(FileUtils.java:1645) at org.codehaus.plexus.util.FileUtils.getFileNames(FileUtils.java:1627) at org.codehaus.plexus.util.FileUtils.getFiles(FileUtils.java:1601) at org.codehaus.plexus.util.FileUtils.getFiles(FileUtils.java:1584) at hudson.plugins.jacoco.ExecutionFileLoader.analyzeStructure(ExecutionFileLoader.java:128) at hudson.plugins.jacoco.ExecutionFileLoader.loadBundleCoverage(ExecutionFileLoader.java:137) at hudson.plugins.jacoco.JacocoReportDir.parse(JacocoReportDir.java:102) at hudson.plugins.jacoco.JacocoBuildAction.loadRatios(JacocoBuildAction.java:291) at hudson.plugins.jacoco.JacocoBuildAction.load(JacocoBuildAction.java:273) at hudson.plugins.jacoco.JacocoPublisher.perform(JacocoPublisher.java:371) at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:770) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:734) at hudson.model.Build$BuildExecution.post2(Build.java:183) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:683) at hudson.model.Run.execute(Run.java:1770) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:89) at hudson.model.Executor.run(Executor.java:240) after the build was otherwise successful. I am using the enhanced project's settings to reuse the workspace of a our main job. Maybe this is related to this kind of setup?

          It is not related to the reuse of the workspace. I changed the settings to let the job use it's own workspace and I get the same error.

          Markus Schlegel added a comment - It is not related to the reuse of the workspace. I changed the settings to let the job use it's own workspace and I get the same error.

          Maninder Singh added a comment - - edited

          Duplicate of JENKINS-27766 . Try to replace .exec with .ec It will found your exec files there ...new system uses .ec instead of .exec but I get jococo/classes not found even when it found the .exec or .ec classed file

          Maninder Singh added a comment - - edited Duplicate of JENKINS-27766 . Try to replace .exec with .ec It will found your exec files there ...new system uses .ec instead of .exec but I get jococo/classes not found even when it found the .exec or .ec classed file

          Andrew Bayer added a comment -

          Looks like a workaround was added in February - https://github.com/jenkinsci/jacoco-plugin/commit/e13d3e3a7a831319d45a56b02e8773813bd5812e. drwoods - do you plan to do a release?

          Andrew Bayer added a comment - Looks like a workaround was added in February - https://github.com/jenkinsci/jacoco-plugin/commit/e13d3e3a7a831319d45a56b02e8773813bd5812e . drwoods - do you plan to do a release?

          Kevin LeBlanc added a comment -

          The workaround referred to above will still fail the build.

          If the classes directory is found but empty the plugin does NOT fail the build, and simply generates an empty report.  This feels like the correct behaviour.  If you want to fail the build due to no classes found this should be a configurable option (just like the other options which control build failures).

          A better fix would be to simply skip any non-existent directories when looking for files to check, rather than letting the exception occur.

           

           

          Kevin LeBlanc added a comment - The workaround referred to above will still fail the build. If the classes directory is found but empty the plugin does NOT fail the build, and simply generates an empty report.  This feels like the correct behaviour.  If you want to fail the build due to no classes found this should be a configurable option (just like the other options which control build failures). A better fix would be to simply skip any non-existent directories when looking for files to check, rather than letting the exception occur.    

            drwoods Donald Woods
            clacke Claes Wallin (韋嘉誠)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: