{"library":"sonarqube-build-breaker","title":"SonarQube Build Breaker","type":"library","description":"The `sonarqube-build-breaker` package is a Node.js module designed to enforce SonarQube quality gates within Continuous Integration (CI) pipelines. It integrates into the build process after `sonar-scanner` has completed its analysis and uploaded results to a SonarQube server. The module then queries the SonarQube server to check the project's quality gate status. If the quality gate is not passed (e.g., due to new critical issues, security vulnerabilities, or code coverage drops), the module will exit with a non-zero status code, effectively failing the CI build. This ensures that code quality standards are met before merging or deploying. Currently at version 0.1.0, its simple, focused functionality implies a stable yet low-cadence maintenance model. Its key differentiator is providing a programmatic way for Node.js projects to hard-fail builds based on SonarQube's quality gate decisions.","language":"javascript","status":"maintenance","last_verified":"Sun Apr 19","install":{"commands":["npm install sonarqube-build-breaker"],"cli":null},"imports":["const sonar = require('sonarqube-build-breaker');","const { checkQuality } = require('sonarqube-build-breaker');","node sonarBreaker.js"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":"https://github.com/NaturesProphet/sonarqube-build-breaker","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/sonarqube-build-breaker","openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"const sonar = require('sonarqube-build-breaker');\n\n// Best practice: use environment variables for sensitive data\nlet token = process.env.SONAR_TOKEN ?? '';\nlet server = process.env.SONAR_SERVER ?? '';\nlet file = './.scannerwork/report-task.txt'; // This file is generated by sonar-scanner\n\nif (!token || !server) {\n  console.error('SONAR_TOKEN and SONAR_SERVER environment variables must be set.');\n  process.exit(1);\n}\n\nsonar.checkQuality(server, file, token)\n  .then(() => {\n    console.log('SonarQube Quality Gate passed.');\n    process.exit(0);\n  })\n  .catch(error => {\n    console.error(`SonarQube Quality Gate failed: ${error.message}`);\n    process.exit(1);\n  });\n\n// Example CI script snippet (e.g., in .travis.yml, github actions workflow, etc.)\n// npm install --save-dev sonarqube-build-breaker\n// # ... other build steps\n// sonar-scanner # Ensure sonar-scanner is installed and configured to run\n// node sonarBreaker.js","lang":"javascript","description":"Demonstrates how to integrate `sonarqube-build-breaker` into a CI pipeline to check SonarQube quality gates using environment variables.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}