Export Code Coverage metrics from SonarQube to Excel

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube

  • what are you trying to achieve
    Export Sonarqube code coverage metrics to Excel

  • what have you tried so far to achieve this

  1. Open an excel sheet and go to Data -->select From Web from Get External Data section.
  2. paste URL in Address section and click on GO button, here you can see your sonar report on the wizard.
  3. click on Import then you will get a wizard to set properties , set properties as you wish to set and hit OK .

Hi,

Welcome to the community!

I don’t know how it works, but we haven’t done anything to facilitate this kind of import into Excel. If you want reports, you’re going to need to build them manually. In the SonarQube page footer you’ll find a link to the Web API, which will allow you to pull data from your instance. It will be JSON formatted & it will be up to you to morph that into a form acceptable to Excel. You’re interested in the api/measures/component or api/measures/component_tree service.

 
Good luck,
Ann

Is it available for community edition as well

Hi @vijit-sonar,

The Web APIs are available for every feature supported in an edition. Just check your page footer for the onboard documentation, which is correct for your version of SonarQube.

 
HTH,
Ann

Dear Ann,

We are actually looking for a similar report for the whole instance. The report we’re trying to get is:
Show all projects in the instance and code coverage for them (optionally with the date when the last scan was done).

This can be done via API, but it will be problematic, because it will require to do /api/project/search over multiple pages and then for each of those, do a api/measures/component query - this will result in hundreds of API calls which will later need to be combined into a single file.

At the same time, the UI is showing this data already, so I am thinking there must be some (simple?) SQL query that could answer the same question. I know of course that normally API is the preferred way, but in this case SQL might be actually a better fit. Before I dig into the DB myself, do you have any suggestions maybe?

Hi @warden,

The official party line is that the DB is a black box into which it’s best not to stick your hands

You may also be interested in Portfolios which are available starting in Enterprise Edition($$).

 
HTH,
Ann