我正在使用SonarQube quality gates plugin for Jenkins。
我的项目有SonarQube ID com.my.package:my-project:origin/feature/WRAP-1-test
和URI com.my.package:my-project:origin%2Ffeature%2FWRAP-1-test
。
在Jenkins的Quality Gates
Project Key
下,我尝试使用ID和URI。
然而,在我建立项目的两个场合,我都得到了:
SonarQube analysis completed: SUCCESS
quality.gates.jenkins.plugin.QGException: Expected status 200, got: 500. Response: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>SonarQube</title>
<style type="text/css">
body {
background-color: #fff;
color: #666;
text-align: center;
font-family: arial, sans-serif;
}
div.dialog {
width: 25em;
padding: 0 4em;
margin: 4em auto 0 auto;
border: 1px solid #ccc;
border-right-color: #999;
border-bottom-color: #999;
}
h1 {
font-size: 100%;
color: #f00;
line-height: 1.5em;
}
</style>
</head>
<body>
<!-- This file lives in public/500.html -->
<div class="dialog">
<h1>We're sorry, but something went wrong.</h1>
<p>Please try back in a few minutes and contact <a href="http://www.sonarqube.org/get-support/">support</a> if the problem
persists.</p>
<p>
<!-- SONAR-4447 Sometimes this error page is served as static html so we hide ruby code -->
<a href="/">Go back to the homepage</a>
<!-- -->
</p>
</div>
</body>
</html>
at quality.gates.sonar.api.SonarHttpRequester.executeGetRequest(SonarHttpRequester.java:59)
at quality.gates.sonar.api.SonarHttpRequester.getAPIInfo(SonarHttpRequester.java:47)
at quality.gates.sonar.api.QualityGatesProvider.getRequesterResult(QualityGatesProvider.java:34)
at quality.gates.sonar.api.QualityGatesProvider.getAPIResultsForQualityGates(QualityGatesProvider.java:29)
at quality.gates.jenkins.plugin.BuildDecision.getStatus(BuildDecision.java:20)
at quality.gates.jenkins.plugin.QGPublisher.perform(QGPublisher.java:73)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:720)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1067)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:665)
at hudson.model.Run.execute(Run.java:1753)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:544)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:404)
Build step 'Quality Gates' marked build as failure
Finished: FAILURE
知道呼叫失败的原因吗?
修改:
我的日志包含以下2个错误:
2017.02.14 15:25:48 ERROR web[AVoyVzS5I0AJ4yijAAU1][rails] Fails to execute http://localhost:9000/api/events?resource=com.my.package:my-project:origin/feature/WRAP-1-test&format=json&categories=Alert : undefined method `generate' for #<JSON::Ext::Generator::State:0x2f8ea6a2>
和
web.log:2017.02.14 15:25:48 ERROR web[AVoyVzS5I0AJ4yijAAU1][o.s.s.ui.JRubyFacade] Fail to render: http://localhost:9000/api/events?resource=com.my.package:my-project:origin/feature/WRAP-1-test&format=json&categories=Alert
/Users/octavian/.rvm/gems/ruby-2.2.1/gems/json-1.8.3/lib/json/common.rb:223:in `generate'
/Users/octavian/.rvm/gems/ruby-2.2.1/gems/json-1.8.3/lib/json/common.rb:470:in `JSON'
/Users/octavian/Downloads/sonarqube-6.2/web/WEB-INF/app/controllers/api/api_controller.rb:48:in `jsonp'
/Users/octavian/Downloads/sonarqube-6.2/web/WEB-INF/app/controllers/api/api_controller.rb:132:in `error_to_json'
/Users/octavian/Downloads/sonarqube-6.2/web/WEB-INF/app/controllers/api/api_controller.rb:123:in `render_response'
我的SonarQube版本为6.2
。
答案 0 :(得分:0)
对于遇到此问题的任何人,我的解决方法是:
sonarqube-6.2/web/WEB-INF/config/environment.rb
,然后更改为ENV['GEM_PATH']=''
。sonar.sh
所在的文件夹并运行unset GEM_PATH
sonar.sh restart
问题是由与安装的ruby版本的一些不兼容引起的。