How to fail maven goal sonar:sonar based on quality gates rules? I run it for local builds, for CI I already wrote a script according to http://docs.sonarqube.org/display/SONAR/Breaking+the+CI+Build So, if quality gates validation fails then goal also should fails
You can use the SonarQube Build Breaker plugin.
It's a controversy feature as explained in the blog post Why You Shouldn't Use Build Breaker.
It is also possible to integrate with Jenkins use web hook (see the blog post Breaking the SonarQube Analysis with Jenkins Pipelines).
If Sonar Qube Version is bigger than 8.1, following command can be used:
mvn verify sonar:sonar -Dsonar.qualitygate.wait=true
I added the script as post step command, so after build succeeded the script check quality gates and breaks the job if they are not ok.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With