sonar-validator

SonarQube Quality Gateway validator

Usage no npm install needed!

<script type="module">
  import sonarValidator from 'https://cdn.skypack.dev/sonar-validator';
</script>

README

Sonar Validator

This NPM module is intended to be run after Sonar-Scanner to evaluate the status of the quality-gate way.

How run

Download the module

npm i sonar-validator

Script in the package.json

Add a new sonar script that will run the validator

package.json
{
    ...
    "scripts": {
        ...
        "sonar": "node node_modules/sonar-validator/"
    }
    ...
}

Environment variable

This module uses following environment vairables

Variable Usage Required/Default
SONARQUBE_URL URL of the SonarQube server Yes / N/A
SONAR_LOGIN SonarQube Token Yes / N/A
SKIP_SONAR Should the Sonar validation be skipped No / false

Output

This module will evaluate the status of the quality gate way and will return an error if the gate has failed.

Sonar Report ---------------

New Reliability Rating OK
New Security Rating OK
New Maintainability Rating OK
New Coverage ERROR
New Duplicated Lines Density OK

Quality Gateway FAILED