How to stop build pipeline on a failed Quality Gate for .NET Sonar extension in Azure DevOps?

Hi There,
We are using Azure DevOps Pipelines with Sonar Extension for .NET. It’s all working fine, and results are uploaded to SonarCloud where the Quality Gate is indicating failed, as it should. Is there a way using the Sonar tool for .NET (or any other way) to stop the build pipeline when the Quality Gate fails?

Hi,

Welcome to the community!

The docs should help.

 
Ann

Hi Ann,

Thank you for your response, and you are correct; I can use that. However, I would like to utilize the QG result for YAML pipelines in CI, not classic release. We want our Azure DevOps YAML CI pipeline to perform the following steps:

Step 1: Build our .NET web applications and then analyze them using SonarCloud.
Step 2: If the QG result is successful, proceed to build Docker images from our apps; otherwise, the pipeline will be halted with an error indicating that the SonarCloud QG analysis has failed.
Step 3: The pipeline will push the created images to our private Docker repository after successfully building, which depends on SonarCloud QG analyses.

Let me know if you have any further questions or if there’s anything else I should consider.

Thank you in advance,
Behrad

Hi Behrad,

I suppose you mean pipelines you’re constructing manually? If so, then this will need to be manual too. Use sonar.qualitygate.wait to pause your pipeline until the analysis report has been processed on SonarCloud, then retrieve the results (or read the webhook payload) and act on the result.

 
HTH,
Ann

1 Like

Hi Ann,
Your solution was perfect and I solved the problem. Instead of webhook I used Web API to get the QG status though.
Thanks for your support,
Behrad

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.