Sonar Coverage Badge
This is a small node.js server that will generate a coverage badge (similar to: http://coveralls.io/) but from a SonarQube server.
Usage
node src\\index.js --port=8087
or
npm start
Then simply specify three parameters:
Example: http://localhost:8087/?server=nemo.sonarqube.org&resource=junit:junit&metrics=coverage&ssl=true
Will display:
Note about SSL
There is a quick way to turn on SSL queries if your SonarQube server requires SSL.
Just add ssl=true
to the end of the query string.
All of the examples in this README referencing Nemo.sonarqube.org have SSL enabled.
Color Settings
To adjust the badge colors, simply update the colorSettings
var at the beginning of the script. Note that it will be evaluated in order.
Samples
JUnit
<a href="http://nemo.sonarqube.org/drilldown/measures/252031?metric=coverage">
<img src="http://localhost:8087/?server=nemo.sonarqube.org&resource=junit:junit&metrics=coverage&ssl=true" />
</a>
JavaScript
<a href="http://nemo.sonarqube.org/drilldown/measures/875157?metric=coverage">
<img src="http://localhost:8087/?server=nemo.sonarqube.org&resource=org.sonarsource.javascript:javascript&metrics=coverage&ssl=true" />
</a>