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

Jacoco Plugin 3.0.1 fails build as basedir now incorrect

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Blocker Blocker
    • jacoco-plugin
    • 3.0.4

      All builds under jacoco plugin 2.2.1 work fine, as soon as i update to 3.0.1 all jobs with jenkins  jacoco plugin start failing.

      I can see now that the 3.0.1 plugin seems to expect the classes to be in build/${BUILD_NUMBER}/jacoco/classes

      whereas my jacoco build folder is set to build/jacoco/

      If i downgrade back to version 2.2.1 it all works again

       

       

       
      Recording test results
      [JaCoCo plugin] Collecting JaCoCo coverage data...
      [JaCoCo plugin] build/jacoco/*.exec;build/classes/main;*/src; locations are configured
      [JaCoCo plugin] Number of found exec files for pattern build/jacoco/**.exec: 1
      [JaCoCo plugin] Saving matched execfiles: /home/jenkins/Documents/jenkins_workspace/workspace/IwTurnFramework/build/jacoco/test.exec
      [JaCoCo plugin] Saving matched class directories for class-pattern: build/classes/main:
      [JaCoCo plugin] Saving matched source directories for source-pattern: **/src:
      [JaCoCo plugin] - /home/jenkins/Documents/jenkins_workspace/workspace/IwTurnFramework/src 1012 files
      [JaCoCo plugin] Loading inclusions files..
      [JaCoCo plugin] inclusions: [**/*.class]
      [JaCoCo plugin] exclusions: []
      ERROR: Build step failed with exception
      java.lang.IllegalStateException: basedir /Volumes/jenkins/Jenkins/Home/jobs/IwTurnFramework/builds/512/jacoco/classes does not exist
      at org.codehaus.plexus.util.DirectoryScanner.scan(DirectoryScanner.java:281)
      at org.codehaus.plexus.util.FileUtils.getFileAndDirectoryNames(FileUtils.java:1940)
      at org.codehaus.plexus.util.FileUtils.getFileNames(FileUtils.java:1868)
      at org.codehaus.plexus.util.FileUtils.getFileNames(FileUtils.java:1850)
      at org.codehaus.plexus.util.FileUtils.getFiles(FileUtils.java:1825)
      at org.codehaus.plexus.util.FileUtils.getFiles(FileUtils.java:1808)
      at hudson.plugins.jacoco.ExecutionFileLoader.analyzeStructure(ExecutionFileLoader.java:124)
      Caused: java.lang.RuntimeException: While reading class directory: /Volumes/jenkins/Jenkins/Home/jobs/IwTurnFramework/builds/512/jacoco/classes
      at hudson.plugins.jacoco.ExecutionFileLoader.analyzeStructure(ExecutionFileLoader.java:131)
      at hudson.plugins.jacoco.ExecutionFileLoader.loadBundleCoverage(ExecutionFileLoader.java:137)
      at hudson.plugins.jacoco.JacocoReportDir.parse(JacocoReportDir.java:110)
      at hudson.plugins.jacoco.JacocoBuildAction.loadRatios(JacocoBuildAction.java:339)
      at hudson.plugins.jacoco.JacocoBuildAction.load(JacocoBuildAction.java:326)
      at hudson.plugins.jacoco.JacocoPublisher.perform(JacocoPublisher.java:631)
      at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81)
      at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
      at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
      at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
      at hudson.model.Build$BuildExecution.post2(Build.java:186)
      at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
      at hudson.model.Run.execute(Run.java:1752)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      at hudson.model.ResourceController.execute(ResourceController.java:97)
      at hudson.model.Executor.run(Executor.java:429)
      Build step 'Record JaCoCo coverage report' marked build as failure

          [JENKINS-49823] Jacoco Plugin 3.0.1 fails build as basedir now incorrect

          centic added a comment -

          I cannot reproduce this, the directory is used by the plugin to store information about the current Jenkins build, so it is not meant to be pointing to your project's build-directory, but rather into the area that Jenkins uses for build-info.

          It seems the problem is that the directory is not existing for you, while it usually always exists at that point.

          One problem could be, that you do not have any matching classes-directory based on your config, also the output above indicates that no files were found under "build/classes/main".

          centic added a comment - I cannot reproduce this, the directory is used by the plugin to store information about the current Jenkins build, so it is not meant to be pointing to your project's build-directory, but rather into the area that Jenkins uses for build-info. It seems the problem is that the directory is not existing for you, while it usually always exists at that point. One problem could be, that you do not have any matching classes-directory based on your config, also the output above indicates that no files were found under "build/classes/main".

          Dell Green added a comment -

          Ok, yep found the problem, back in August we upgraded jobs from gradle 3 to gradle 4 which automatically changed the classes path from 'build/classes/main' to 'build/classes/java/main'. Nobody noticed as jacoco plugin 2.2.1 didn't fail the build but completed with success. So with jacoco 3.0.1 now failing the build,  I change my initial assessment to this being a welcome feature not a bug. Do you want me to close the ticket?

          Dell Green added a comment - Ok, yep found the problem, back in August we upgraded jobs from gradle 3 to gradle 4 which automatically changed the classes path from 'build/classes/main' to 'build/classes/java/main'. Nobody noticed as jacoco plugin 2.2.1 didn't fail the build but completed with success. So with jacoco 3.0.1 now failing the build,  I change my initial assessment to this being a welcome feature not a bug. Do you want me to close the ticket?

          centic added a comment -

          I think the error message is borked and should be improved, so let's keep it open, anybody up for a PR? Should not be too hard to check this upfront and fail more obviously.

          centic added a comment - I think the error message is borked and should be improved, so let's keep it open, anybody up for a PR? Should not be too hard to check this upfront and fail more obviously.

          Mor L added a comment - - edited

          Hi,

          For me this is actually a major problem - I have a generic flow which "suits-all" - some repositories produce jacoco reports while others don't - but I always call the jacoco step . In previous versions of the plugin this found nothing and the job continued properly. with the new plugin version my builds started to fail due to the above mentioned error - so I'm going to downgrade it.

          I would expect at least an option to not fail the build if classes/exec files are not found - same as exists for the Junit and TestNG plugins. If needed I can open a new ticket for this request.

          Mor L added a comment - - edited Hi, For me this is actually a major problem - I have a generic flow which "suits-all" - some repositories produce jacoco reports while others don't - but I always call the jacoco step . In previous versions of the plugin this found nothing and the job continued properly. with the new plugin version my builds started to fail due to the above mentioned error - so I'm going to downgrade it. I would expect at least an option to not fail the build if classes/exec files are not found - same as exists for the Junit and TestNG plugins. If needed I can open a new ticket for this request.

          centic added a comment -

          You are welcome to send a PR for this, the code and the change is not complicated, the plugin is just short on active maintainers...

          centic added a comment - You are welcome to send a PR for this, the code and the change is not complicated, the plugin is just short on active maintainers...

          Michael Kotten added a comment - I fixed this in  https://github.com/jenkinsci/jacoco-plugin/pull/100

          centic Did you have a look at the changes?

           

          Michael Kotten added a comment - centic Did you have a look at the changes?  

          centic added a comment - - edited

          Change is merged to master now, will be released as part of 3.0.3

          centic added a comment - - edited Change is merged to master now, will be released as part of 3.0.3

          it's been a month, when will the next release happen that incorporates this fix?

          Alan Czajkowski added a comment - it's been a month, when will the next release happen that incorporates this fix?

          centic added a comment -

          This is available now with release 3.0.4

          centic added a comment - This is available now with release 3.0.4

            centic centic
            dellgreen Dell Green
            Votes:
            4 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: