sonarqube-build-breaker

0.1.0 • Public • Published

Build StatusCommitizen friendlyConventional Commits

sonarqube-build-breaker

Node module to be used on CI Pipelines of Node.js projects after a sonar-scanner run. If the sonarqube server reproves de quality of the code analysed, the build will be breaked.

Instalation

use npm and save it as dev dependencie:

npm install --save-dev sonarqube-build-breaker

How to use this module in your CI

create a empty file named 'sonarBreaker.js' in the root directory of your repository, and then, put this code on it:

const sonar = require( 'sonarqube-build-breaker' );

let token = YOUR_SONAR_TOKEN; //best way is process.env.SONAR_TOKEN;
let server = YOUR_SONARQUBE_SERVER_ADDRESS; //best way is process.env.SONAR_SERVER;
let file = './.scannerwork/report-task.txt'; // this is a file generated by sonar-scanner execution

sonar.checkQuality( server, file, token );

add this file to be executed on your CI script. this is an example based on Travis-CI:

language: 
- node_js
- java
node_js:
- "node"
dist: trusty
addons:
 sonarcloud:
   organization: "$SONAR_ORGANIZATION"
   token:
     secure: "$SONAR_TOKEN"
script:
- npm install
- sonar-scanner
- node sonarBreaker.js

Package Sidebar

Install

npm i sonarqube-build-breaker

Weekly Downloads

35

Version

0.1.0

License

Apache-2.0

Unpacked Size

20.4 kB

Total Files

9

Last publish

Collaborators

  • mateus.garcia