Interview Prep/CI/CD/Testing and Quality Gates

How do you integrate SonarQube into a CI pipeline and make it block on gate failure?

IntermediateConceptTesting and Quality Gates
Answer

Run the scanner with the server URL and a token, then wait for the gate result. For Maven: mvn sonar:sonar. For generic scanning use sonar-scanner with -Dsonar.qualitygate.wait=true, which makes the scanner block and exit non-zero when the gate fails. In Jenkins, waitForQualityGate abortPipeline: true after withSonarQubeEnv does the same via a webhook.

sonar-scanner \
  -Dsonar.projectKey=shop-api \
  -Dsonar.host.url=https://sonar.example.com \
  -Dsonar.token=$SONAR_TOKEN \
  -Dsonar.qualitygate.wait=true
All CI/CD questions Roadmap: CI/CD fundamentals

More on Testing and Quality Gates