I am experiencing an issue with getting Sonarcloud to fail a PR in GitHub when a quality check fails. Sonarcloud correctly reports that there has been code added that is a duplication of other code. However, the CI reports that it is successful and allows a merge. The Sonar code analysis has been set up to be required to pass in the settings of the repo.
I finally figured out what the issue was. We are using the gradle plugin and a dockerfile to run the scan. I had to add the property -Dsonar.qualitygate.wait=true. This waited for sonar to return the quality gate and fail the build.