Azure DevOps: how to break CI build if quality gate conditions fail to meet

SonarQube : * Enterprise Edition* Version 8.4.1 (build 35646),
Scanner: 4.3.0.2102

  • what are you trying to achieve : Fail CI build if the analysis of project fail to meet quality gate

  • what have you tried so far to achieve this: we tried a python script to call the API for project status and fail the build accordingly. But it would be great if we have option via sonar scanner itself

Hi,

We do not recommend failing your entire build. Instead, you can add a Branch Policy on your quality gate upon pull requests, and block them from merging if the Quality Gate fails.

Check this video here to learn how.

Cheers,
Daniel

Hello Daniel,

Thanks for your response. We do have the PR rules setup done. But as per Org practices, we would like to have this feature as well.

Hi,

This is not possible today. As explained in our docs:

How can I break the build based on the Quality Gate status?
We believe that breaking a CI build is not the right approach.

Instead, we are providing pull request decoration (to make sure that issues aren’t introduced at merge time) and we’ll soon add a way to check the quality gate as part of a Release process.

Cheers,
Daniel