Gradle SonarRunner:在失败的Quality Gate上构建失败

时间:2015-12-08 10:52:26

标签: android gradle sonarqube teamcity sonar-runner

我正在我的Android代码上执行Gradle SonarRunner任务,作为Team City构建的一部分。

SonarQube上的Quality Gate失败,但是控制台构建成功,日志中没有关于QG失败的信息:

[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

我想通过Gradle任务失败或至少检查日志中的某些特定失败消息(例如“ANALYSIS FAILED”)来识别此类事件。我怎么能做到这一点?

2 个答案:

答案 0 :(得分:3)

您没有提及您的SonarQube服务器版本。打破构建在当前服务器版本5.2中不可用,但是在v5.1中以及之前使用the Build Breaker Plugin和本机支持should return soon

答案 1 :(得分:0)

在Sonarqube 7.7之后,构建破坏者似乎不再起作用。

从1.3.0版本开始,此Android Gradle插件具有构建破坏者功能,您可能需要检查一下:https://github.com/pinchbv/android-analyzer