How to make sonarqube see GCovr cobertura reports

  • ALM used (GitHub)
  • CI system used (Github Actions)
  • C++17, CMake
    Please help me how to let sonar-scanner pick up cobertura reports from gcovr.

Hey there.

To “pick up” GCovr reports and make sure they’re imported into SonarQube, you will need to pass the path to the directory containing the native .gcov reports to sonar.cfamily.gcov.reportsPath

This is noted in our documentation on Test Coverage and Execution


Analysis parameter Description
sonar.cfamily.gcov.reportsPath Path to the directory containing native *.gcov reports (not the XML reports generated by gcovr)

Based on the gcovr documentation there is even a sonarqube output format that can be imported as generic coverage data if that is somehow easeir for you.

SonarQube does not accept the cobertura format of gcovr reports for reporting test coverage.


Hi, gcovr developer here. Gcovr does not currently create .gcov reports. So using the gcovr --sonarqube output format is the only supported option to connect our respective tools.

Both XML formats (SonarQube and Cobertura) provide equivalent information. If necessary, it is possible to generate multiple reports in one go, e.g.:

gcovr OPTIONS --sonarqube sonar.xml --xml cobertura.xml

If raw .gcov files are desired, it would be necessary to run gcov manually (without gcovr). The -l/--long-file-names option should be used to get correct coverage information in header files, and either -x/--hash-filenames or -p/--preserve-paths if multiple source files have the same base name.

1 Like

@latk thanks for clarifying — I didn’t quite realise the distinction between gcov and gcovr. Really appreciate it!