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.
npm install sonarqube-build-breakerVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to integrate `sonarqube-build-breaker` into a CI pipeline to check SonarQube quality gates using environment variables.
Ensure `sonar-scanner` is run and completes successfully before invoking `sonarqube-build-breaker` in your CI script.
Verify the exact location of `report-task.txt` in your CI environment and adjust the `file` parameter accordingly. For monorepos, pay extra attention to the working directory.
Configure your CI environment to securely provide `SONAR_TOKEN` and `SONAR_SERVER` as environment variables.
Verify that `sonar-scanner` executed successfully prior to `sonarqube-build-breaker` and check the actual path where `report-task.txt` is generated, then update the `file` parameter in your script.
Ensure you are using the CommonJS `require` syntax: `const sonar = require('sonarqube-build-breaker');`.Double-check that the `SONAR_TOKEN` environment variable (or wherever you're providing the token) is correct and has sufficient permissions on your SonarQube instance.
Review the SonarQube analysis results for your project, address the identified code quality issues, and rerun the analysis.
No dependency data recorded yet.