'Fail Gitlab commit when not passing Sonarqube Quality Gates

For integrating Sonarqube with my Gitlab CI, I want a commit to fail when it doesn't pass the Quality Gate in Sonarqube. I have set up my .gitlab-ci.yml to analyze every commit with Sonarqube, but the commit is succesfull regardless of the outcome. As long as the scan is completed succesfully, the commit is passed. How can I make sure my commit fails when it doesn't pass the Quality Gate in Sonarqube?

I have set everything up based on this post: SonarQube autorun with gitlab



Solution 1:[1]

You're probably missing the parameter sonar.qualitygate.wait=true

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Guillermo Martinez