Interview Prep/DevSecOps/SAST, SCA and secrets scanning in CI

SonarQube shows 0% coverage and the "Coverage on New Code" condition fails, although tests pass

IntermediateTroubleshootingSAST, SCA and secrets scanning in CI
Answer

Likely causes → The coverage report is not produced, is produced after the scanner runs, or the path property is wrong (sonar.javascript.lcov.reportPaths, sonar.coverage.jacoco.xmlReportPaths, sonar.python.coverage.reportPaths). Paths inside the report do not match repo paths (containers, /app/src).

Diagnose →

ls -la coverage/lcov.info target/site/jacoco/jacoco.xml
grep -m3 '^SF:' coverage/lcov.info

Check scanner logs for Could not resolve N file paths.

Fix → Run tests with coverage first, point the property at the file, and rewrite paths if tests ran in a container (sed -i 's#/app/#./#' coverage/lcov.info).

Prevent → Keep scanner config in sonar-project.properties in the repo and fail the job if the report file is missing.

All DevSecOps questions Roadmap: Security in the pipeline

More on SAST, SCA and secrets scanning in CI