Sonarcloud not blocking MR on gitlab even if the sonar scan is not passed

We have followed all the suggested steps in the link, and still sonar scanner is not able to block the MR. Requesting help on where it is having issues. Also, to inform that we have given only read permissions to the sonar API/token.

Hey there.

You’ll have to give us some more issues, preferably some screenshots that reflect what you’ve read in this guide, a copy of your GitLab CI YAML, screenshots of SonarQube Cloud / Gitlab… the more information you provide, the more likely somebody can be useful!

Here is the snapshot for the gitlab ci file.

I have also added " -Dsonar.qualitygate.wait=true" to script part.

You probably want to try and upload that screenshot again, along with the other information I mentiond!

Updated the comment. Thank you! Also, you please let me know what other specific information you will need to check?

You said the sonar-scanner is not able to block the Merge Request. Do you have a screenshot where the execution of the sonar-scanner failed (due to a failing Quality Gate) but the build has not failed or the merge of the PR isn’t blocked?

If you were showing this problem to somebody sitting next to you, what would you show them to demonstrate the issue? All of those things are necessary to debug an issue, even in async communication. :slight_smile:

Also, it looks like you’ve set sonar.branch.name=true, which means you will always have a branch analysis (not a Merge Request analysis). You should remove this setting and let the scanner auto-detect these things based on the environment.

Okay!
So, first thing I would not be able to share certain screenshots due to critical & confidential nature of code. But the overall issue is that we have sonar cloud token with read access to our onboarded repos from gitlab and secondly we want them to be blocked if certain custom rules are breached while requesting the same for merge. How can we achieve that?

You’ve referenced the guide that describes how to do that. You said it didn’t work for you. You’re going to have to provide more details, otherwise there’s really no way for this community to support you!