On this page

Failing a pipeline job when the quality gate failsGitLab CI/CDAzure PipelinesBitbucket PipelinesJenkins

Overview

Merge and Pull Request analysis is available as part of Developer Edition and above.

SonarScanners running in GitLab CI/CD, Azure Pipelines, Cirrus CI, and Jenkins with a Branch Source plugin configured can automatically detect branches and merge or pull requests by using environment variables set in the jobs.

Failing a pipeline job when the quality gate fails

If you're using Jenkins, you can suspend pipeline execution until the analysis' Quality Gate status is known. See the Jenkins integration page.

For other CIs, you can use the sonar.qualitygate.wait=true analysis parameter in your configuration file. Setting sonar.qualitygate.wait to true forces the analysis step to poll your SonarQube instance until the Quality Gate status is available. This increases the pipeline duration and causes the analysis step to fail any time the Quality Gate fails, even if the actual analysis is successful. You should only use this parameter if it's necessary.

You can set the sonar.qualitygate.timeout property to the number of seconds that the scanner should wait for a report to be processed. The default is 300 seconds.

GitLab CI/CD

For GitLab CI/CD configuration, see the GitLab integration page.

Azure Pipelines

For Azure Pipelines configuration, see the Azure DevOps integration page.

Bitbucket Pipelines

For Bitbucket Pipelines configuration, see the Bitbucket Cloud integration page.

Jenkins

For Jenkins configuration, see Jenkins.

© 2008-2022, SonarSource S.A, Switzerland. Except where otherwise noted, content in this space is licensed under a Creative Commons Attribution-NonCommercial 3.0 United States License. SONARQUBE is a trademark of SonarSource SA. All other trademarks and copyrights are the property of their respective owners.

Creative Commons License