Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fail maven goal sonar:sonar based on quality gates

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

like image 332
rrader Avatar asked Apr 01 '16 14:04

rrader


3 Answers

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).

like image 167
Nicolas Henneaux Avatar answered Oct 16 '22 15:10

Nicolas Henneaux


If Sonar Qube Version is bigger than 8.1, following command can be used:

mvn verify sonar:sonar -Dsonar.qualitygate.wait=true
like image 4
kaan bobac Avatar answered Oct 16 '22 14:10

kaan bobac


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.

like image 3
rrader Avatar answered Oct 16 '22 15:10

rrader