Error parsing of generic coverage report - No such file or directory

Hey guys. Our repository have both C and Python source codes and whenever we run the sonar pipeline, we’re getting some errors. So basically, we just want our 100% coverage python codes to show up in the SonarCloud dashboard. Right now, the coverage shows the following in the pipeline logs:

But then it’s not reflecting the same percentage in the sonar dashboard:

Please see details below.

  • ALM: Bitbucket Cloud
  • CI System: Bitbucket Cloud
  • Sonar project properties:
sonar.exclusions=lib/**/*
sonar.coverageReportPaths=build/artifacts/gcov/GcovCoverageSonarQube.xml
sonar.python.coverage.reportPaths=coverage.xml
  • Scanner commands:
- step: &sonarcloud-for-python
    name: Analyze on SonarCloud
    caches:
      - sonar
    script:
      - pipe: sonarsource/sonarcloud-scan:1.2.2
      - pipe: sonarsource/sonarcloud-quality-gate:0.1.4
  • Languages of repo: C, Python
  • Error observed:
...
INFO: Sensor Generic Coverage Report
INFO: Parsing /opt/atlassian/pipelines/agent/build/build/artifacts/gcov/GcovCoverageSonarQube.xml
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 51.806s
INFO: Final Memory: 43M/168M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
ERROR: Error during parsing of the generic coverage report '/opt/atlassian/pipelines/agent/build/build/artifacts/gcov/GcovCoverageSonarQube.xml'. Look at SonarQube documentation to know the expected XML format.
ERROR: Caused by: /opt/atlassian/pipelines/agent/build/build/artifacts/gcov/GcovCoverageSonarQube.xml (No such file or directory)
ERROR: 
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
✖ SonarCloud analysis failed. (exit code = 2)
1 Like

Hey there.

The error you’re receiving right now doesn’t seem related to Python code coverage, but that the file you’ve specified for sonar.coverageReportPaths doesn’t exist.

What happens if you remove the sonar.coverageReportPaths setting, or ensure that the file you’ve specified actually exists?

Hello, Colin. Thanks for your response.

I have tried removing that line but then it will throw an error regarding C files:

INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 55.150s
INFO: Final Memory: 43M/160M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
java.lang.UnsupportedOperationException: 

The only way to get an accurate analysis of C/C++/Objective-C files is by using the SonarSource build-wrapper and setting the property "sonar.cfamily.build-wrapper-output" or by using Clang Compilation Database and setting the property "sonar.cfamily.compile-commands". None of these two options were specified.

If you don't want to analyze C/C++/Objective-C files, then prevent them from being analyzed by setting the following properties:
    sonar.c.file.suffixes=-
    sonar.cpp.file.suffixes=-
    sonar.objc.file.suffixes=-

...

I then also tried adding those line in my sonar project properties as follows:

sonar.exclusions=lib/**/*

# sonar.coverageReportPaths=build/artifacts/gcov/GcovCoverageSonarQube.xml
sonar.c.file.suffixes=-
sonar.cpp.file.suffixes=-
sonar.objc.file.suffixes=-

sonar.python.coverage.reportPaths=coverage.xml

With this, the sonarsource/sonarcloud-scan:1.2.2 succeeds. But the next line sonarsource/sonarcloud-quality-gate:0.1.4 now throws an error:

Unable to find image 'sonarsource/sonarcloud-quality-gate:0.1.4' locally
0.1.4: Pulling from sonarsource/sonarcloud-quality-gate
...
Status: Downloaded newer image for sonarsource/sonarcloud-quality-gate:0.1.4
✖ Quality Gate failed
- Coverage on New Code: 0.0 (is less than 70)

Please help. Btw, it is possible to run code coverage for a repo with both C and Python, right?

This question was solved via this post:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.