SonarQube Build Breaker不报告故障

时间:2014-08-18 20:26:03

标签: jenkins sonarqube

当代码没有通过质量门时,我想在Jenkins中失败。但由于某种原因,Build breaker插件不报告失败,我不知道理解为什么。

  • SonarQube 4.4
  • Build breaker v.1.1

Jenkins的输出,项目名称和设置已重命名。

20:01:07 + mvn sonar:sonar -Dsonar.jdbc.url=jdbc:postgresql://something:5432/sonarqube -Dsonar.jdbc.username=something -Dsonar.jdbc.password=something -Dsonar.host.url=http://something -Dsonar.jacoco.itReportPath=target/jacoco-it.exec -Dsonar.junit.reportsPath=target/surefire-reports -Dsonar.analysis.mode=preview -Dsonar.issuesReport.html.enable=true -Dsonar.issuesReport.console.enable=true -Dsonar.preview.includePlugins=buildbreaker -Dsonar.preview.excludePlugins=devcockpit,jira,pdfreport,views,report,buildstability,scmactivity
20:01:08 [INFO] Scanning for projects...
20:01:09 [INFO]                                                                         
20:01:09 [INFO] ------------------------------------------------------------------------
20:01:09 [INFO] Building some-project
20:01:09 [INFO] ------------------------------------------------------------------------
20:01:10 [INFO] 
20:01:10 [INFO] --- sonar-maven-plugin:2.4:sonar (default-cli) @ some-project ---
20:01:10 [INFO] SonarQube version: 4.4
20:01:11 INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
20:01:11 INFO: Work directory: /var/lib/jenkins/jobs/some-project_review-1/workspace-34_2014-08-18_20-00-17/target/sonar
20:01:11 INFO: SonarQube Server 4.4
20:01:11 [INFO] [20:01:11.651] Preview mode
20:01:11 [INFO] [20:01:11.656] Load global settings
20:01:11 [INFO] [20:01:11.815] User cache: /var/lib/jenkins/.sonar/cache
20:01:11 [INFO] [20:01:11.824] Install plugins
20:01:11 [INFO] [20:01:11.845] Include plugins: buildbreaker
20:01:11 [INFO] [20:01:11.845] Exclude plugins: devcockpit, jira, pdfreport, views, report, buildstability, scmactivity
20:01:12 [INFO] [20:01:12.019] Create JDBC datasource for jdbc:h2:/var/lib/jenkins/jobs/some-project_review-1/workspace-34_2014-08-18_20-00-17/target/sonar/.sonartmp/preview1408392071940-0
20:01:12 [INFO] [20:01:12.692] Initializing Hibernate
20:01:17 [INFO] [20:01:17.535] Loading technical debt model...
20:01:17 [INFO] [20:01:17.653] Loading technical debt model done: 118 ms
20:01:17 [INFO] [20:01:17.666] Load project settings
20:01:17 [INFO] [20:01:17.730] Apply project exclusions
20:01:18 [INFO] [20:01:18.081] -------------  Scan Something Project
20:01:18 [INFO] [20:01:18.086] Load module settings
20:01:19 [INFO] [20:01:19.327] Loading rules...
20:01:20 [INFO] [20:01:20.190] Loading rules done: 863 ms
20:01:20 [INFO] [20:01:20.233] Configure Maven plugins
20:01:20 [INFO] [20:01:20.415] Compare to previous analysis (2014-08-18)
20:01:20 [INFO] [20:01:20.438] Compare over 30 days (2014-07-19, analysis of 2014-08-18 17:26:53.918)
20:01:20 [INFO] [20:01:20.472] Loaded quality gate 'something'
20:01:20 [INFO] [20:01:20.680] Initializer FindbugsMavenInitializer...

[a lot of extra output excluded that I guess it not needed]

20:01:45 [INFO] [20:01:45.181] Export results to /var/lib/jenkins/jobs/some-project_review-1/workspace-34_2014-08-18_20-00-17/target/sonar/sonar-report.json
20:01:45 [INFO] [20:01:45.204] Store results in database
20:01:46 [INFO] [20:01:46.088] ANALYSIS SUCCESSFUL
20:01:46 [INFO] [20:01:46.089] Executing post-job class org.sonar.issuesreport.ReportJob
20:01:46 [INFO] [20:01:46.601] HTML Issues Report generated: /var/lib/jenkins/jobs/some-project_review-1/workspace-34_2014-08-18_20-00-17/target/sonar/issues-report/issues-report.html
20:01:46 [INFO] [20:01:46.684] Light HTML Issues Report generated: /var/lib/jenkins/jobs/some-project_review-1/workspace-34_2014-08-18_20-00-17/target/sonar/issues-report/issues-report-light.html
20:01:46 [INFO] [20:01:46.690] 
20:01:46 
20:01:46 -------------  Issues Report  -------------
20:01:46 
20:01:46         +3 issues
20:01:46 
20:01:46         +3 major
20:01:46 
20:01:46 -------------------------------------------
20:01:46 
20:01:46 
20:01:46 [INFO] [20:01:46.690] Executing post-job class org.sonar.plugins.buildbreaker.AlertBreaker
20:01:46 [INFO] [20:01:46.703] Executing post-job class org.sonar.plugins.buildbreaker.ForbiddenConfigurationBreaker
20:01:46 [INFO] ------------------------------------------------------------------------
20:01:46 [INFO] BUILD SUCCESS
20:01:46 [INFO] ------------------------------------------------------------------------
20:01:46 [INFO] Total time: 38.148s
20:01:46 [INFO] Finished at: Mon Aug 18 20:01:46 UTC 2014
20:01:47 [INFO] Final Memory: 35M/744M
20:01:47 [INFO] ------------------------------------------------------------------------
20:01:47 Finished: SUCCESS

1 个答案:

答案 0 :(得分:2)

根据声纳,您需要将项目与质量门关联起来。

参见1. USAGE

部分

SonarQube documentation

就我而言,我在信息中心上点击项目,在右上角点击配置和质量门。

看起来默认为空并将其更改为SonarWay(或您自己的)。别忘了点击更新按钮