Gradle SonarRunner: fail build on failed Quality Gate Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Gradle SonarRunner: fail build on failed Quality Gate without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I am executing Gradle SonarRunner task on my Android code as a part of Team City build.

It fails Quality Gate on SonarQube, but console build is successful and there is no info about failed QG in logs:

[10:57:35][Step 1/3] 10:57:36.323 INFO  - Loaded quality gate 'Android'
[10:57:36][Step 1/3] 10:57:36.397 INFO  - Compare to previous analysis (2015-12-07)
[10:57:36][Step 1/3] 10:57:36.405 INFO  - Compare over 30 days (2015-11-08, analysis of Thu Nov 26 13:27:50 CET 2015)
[10:57:36][Step 1/3] 10:57:36.411 INFO  - Compare to previous version (2015-12-07)
[10:57:36][Step 1/3] 10:57:36.642 INFO  - Execute decorators...
[10:58:19][Step 1/3] 10:58:20.189 INFO  - Store results in database
[10:58:59][Step 1/3] 10:59:00.330 INFO  - Analysis reports generated in 2698ms, dir size=4 MB
[10:59:09][Step 1/3] 10:59:09.888 INFO  - Analysis reports compressed in 9558ms, zip size=3 MB
[10:59:09][Step 1/3] 10:59:10.245 INFO  - Analysis reports sent to server in 357ms
[10:59:09][Step 1/3] 10:59:10.245 INFO  - ANALYSIS SUCCESSFUL, you can browse [###############]
[10:59:09][Step 1/3] 10:59:10.245 INFO  - Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report.
[10:59:10][Step 1/3] INFO: ------------------------------------------------------------------------
[10:59:10][Step 1/3] INFO: EXECUTION SUCCESS
[10:59:10][Step 1/3] INFO: ------------------------------------------------------------------------
[10:59:10][Step 1/3] Total time: 6:05.725s
[10:59:10][Step 1/3] Final Memory: 44M/1294M
[10:59:10][Step 1/3] INFO: ------------------------------------------------------------------------
[10:59:10][Step 1/3] 
[10:59:10][Step 1/3] BUILD SUCCESSFUL

I’d like to recognize such event by failing Gradle task or at least checking logs for some specific failure message (eg. “ANALYSIS FAILED”). How can I achive this?


You don’t mention your SonarQube Server version. Breaking the build is not available in the current server version, 5.2, but was there in v5.1 and before with the Build Breaker Plugin, and native support should return soon.

We are here to answer your question about Gradle SonarRunner: fail build on failed Quality Gate - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji