SonarQube coverage report not imported / 0% coverage in CI
Sonar reports 0% coverage because the coverage report was never imported: the reportPaths property pointed to a missing file, a wrong format, or paths the scanner could not match to source files.
What this error means
Sonar shows 0% coverage despite passing tests, and the log warns "Coverage report ... could not be read" or "cannot resolve the file path ... of the coverage report."
WARN: Could not resolve 70 file paths in [coverage.xml], first unresolved path:
src/app/main.py (report path: coverage.xml)Common causes
reportPaths points at a missing or wrong file
The coverage file was not generated before the scan, or the property names a path that does not exist in the job.
Report paths do not match scanned sources
Relative paths in the coverage XML do not resolve against sonar.sources, so Sonar cannot attribute coverage to files.
How to fix it
Generate coverage, then point Sonar at it
- Produce the coverage report in the format Sonar expects for your language.
- Set the language-specific
reportPathsproperty to that file. - Run the scan after the report exists and confirm coverage is non-zero.
# sonar-project.properties
sonar.sources=src
sonar.python.coverage.reportPaths=coverage.xmlAlign coverage paths with sonar.sources
Generate coverage from the repository root so report paths resolve against the scanned source directory.
coverage run -m pytest && coverage xml -o coverage.xmlHow to prevent it
- Run the test/coverage step before the Sonar scan.
- Use the correct
reportPathsproperty for each language. - Keep coverage paths relative to the repository root.