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

Cobertura plugin is not able to find code from python coverage

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Our repository has all src code under /src. So when running tests and coverage the coverage.xml file is generated in $WORKSPACE/src. In the job config I specify **/coverage.xml in the location. Th eCobertura plugin finds the coverage report but states:

      Source code is unavailable. Some possible reasons are:

      This is not the most recent build (to save on disk space, this plugin only keeps the most recent builds source code).
      Cobertura found the source code but did not provide enough information to locate the source code.
      Cobertura could not find the source code, so this plugin has no hope of finding it.

      I believe this is due to the fact that coverage.xml records the relative path to the files. As this file is in $WORKSPACE/src I would expect it to find the files in $WORKSPACE/src/<relative path>, but I susepct it's omitting the 'src' directory.

        Attachments

          Activity

          Hide
          tessarakt Jens Müller added a comment -

          And I should add that I use an absolute path for the <source> element and paths relative to it for the filename attribute, as in the attached example produced by Cobertura. And still I get the error message about missing source code.

          Show
          tessarakt Jens Müller added a comment - And I should add that I use an absolute path for the <source> element and paths relative to it for the filename attribute, as in the attached example produced by Cobertura. And still I get the error message about missing source code.
          Hide
          sogabe sogabe added a comment -

          See coverage_by_cobertura.xml.
          proper documentation? I don't know where it is.

          Show
          sogabe sogabe added a comment - See coverage_by_cobertura.xml. proper documentation? I don't know where it is.
          Hide
          tonylampada Tony Lampada added a comment -

          I found a workaround for this.
          Basically you need to make sure your build script leaves the coverage.xml file and the source code it links to relative to the workspace root.

          for example, here's a piece of my workspace structure:

          src
          -- estantemagica
          ---- core
          ------ *.py
          

          and my previous build script:

          cd src/estantemagica
          coverage erase
          coverage run --source='core' manage.py test --noinput core
          coverage xml
          

          and then I told Jenkins to publish the xml report from src/estantemagica/coverage.xml
          It doesn't find the files.

          Then I changed the build script to:

          cd src/estantemagica
          coverage erase
          coverage run --source='core' manage.py test --noinput core
          coverage xml
          cp -Rf * ../../
          

          and then I told Jenkins to publish the xml report from coverage.xml

          Then it works.

          Show
          tonylampada Tony Lampada added a comment - I found a workaround for this. Basically you need to make sure your build script leaves the coverage.xml file and the source code it links to relative to the workspace root. for example, here's a piece of my workspace structure: src -- estantemagica ---- core ------ *.py and my previous build script: cd src/estantemagica coverage erase coverage run --source= 'core' manage.py test --noinput core coverage xml and then I told Jenkins to publish the xml report from src/estantemagica/coverage.xml It doesn't find the files. Then I changed the build script to: cd src/estantemagica coverage erase coverage run --source= 'core' manage.py test --noinput core coverage xml cp -Rf * ../../ and then I told Jenkins to publish the xml report from coverage.xml Then it works.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Karol Judek
          Path:
          src/main/java/hudson/plugins/cobertura/CoberturaPublisher.java
          http://jenkins-ci.org/commit/cobertura-plugin/2ea94adb834c8dbd0c614b8eb93748c43e595150
          Log:
          [FIXED JENKINS-13889] Not able to find source code from subdirectories

          Code style fixes

          Fix line endings

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Karol Judek Path: src/main/java/hudson/plugins/cobertura/CoberturaPublisher.java http://jenkins-ci.org/commit/cobertura-plugin/2ea94adb834c8dbd0c614b8eb93748c43e595150 Log: [FIXED JENKINS-13889] Not able to find source code from subdirectories Code style fixes Fix line endings
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Arcadiy Ivanov
          Path:
          src/main/java/hudson/plugins/cobertura/CoberturaPublisher.java
          http://jenkins-ci.org/commit/cobertura-plugin/a94a23f2570e27c7405290e57857ca9179156876
          Log:
          Merge pull request #43 from dzudek/master

          [FIXED JENKINS-13889] Not able to find source code from subdirectories

          Compare: https://github.com/jenkinsci/cobertura-plugin/compare/c27a7e591747...a94a23f2570e

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Arcadiy Ivanov Path: src/main/java/hudson/plugins/cobertura/CoberturaPublisher.java http://jenkins-ci.org/commit/cobertura-plugin/a94a23f2570e27c7405290e57857ca9179156876 Log: Merge pull request #43 from dzudek/master [FIXED JENKINS-13889] Not able to find source code from subdirectories Compare: https://github.com/jenkinsci/cobertura-plugin/compare/c27a7e591747...a94a23f2570e

            People

            • Assignee:
              stephenconnolly Stephen Connolly
              Reporter:
              cangove cangove
            • Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: