Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to embed coverage from SonarQube into a Github project as an icon?

Is it possible to embed code coverage results (stored in SonarQube) into Github projects as one of those embeddable icon gadgets (not sure what their name is; it would be great if somebody to tell me that as well)...? I'm referring to the ones that show the build status, for example.

like image 350
carlspring Avatar asked Nov 16 '15 14:11

carlspring


People also ask

What is SonarQube code coverage?

Code coverage, also called test coverage, is a measure of how much of the application's code has been run in testing. Essentially, it's a metric that many teams use to check the quality of their tests because it represents the percentage of the production code that has been tested and run.


2 Answers

Using a plugin in no longer needed, as some new APIs are now added that will do what you want. You can use this snippet in your .md files:

[![SonarCloud Coverage](https://{domain}/api/project_badges/measure?project={projectName}&metric=coverage)](https://{domain}/component_measures/metric/coverage/list?id={projectName})

Note that you have to replace parameters inside {}s with your own values. If you are using on-premise version, the domain will be your own domain and if you are using cloud version, it will be sonarcloud.io.

Also note that this will work only for public projects. For private ones, I could not find any solution.

And finally as a side note, the metric parameter takes some values other than coverage and gives other fantastic badges that you may find helpful:

bugs, code_smells, coverage, duplicated_lines_density, ncloc, sqale_rating, alert_status, reliability_rating, security_rating, sqale_index, vulnerabilities
like image 58
Ahmad Avatar answered Oct 21 '22 10:10

Ahmad


The only thing currently available is this under-development plugin, which was first discussed in this Google Group thread. Note that this project appears to be in its infancy.

EDIT

This plugin has since been released, and can be installed directly from the Update Center

EDIT 2

With SonarQube 7.1, badges become a native feature.

like image 38
G. Ann - SonarSource Team Avatar answered Oct 21 '22 12:10

G. Ann - SonarSource Team