Skip to content

A simple node.js server that will display badges for Code Coverage from a source SonarQube server

Notifications You must be signed in to change notification settings

stschmitt/sonar-coverage-badge

 
 

Repository files navigation

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:

  • *server* - Hostname of the target SonarQube server
  • *resource* - the key as defined by http://{SONAR}/api/projects
  • *metrics* - usually either 'coverage' or 'branch_coverage'
  • 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>
    

    About

    A simple node.js server that will display badges for Code Coverage from a source SonarQube server

    Resources

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published

    Languages

    • JavaScript 89.3%
    • Makefile 9.6%
    • Smarty 1.1%