SonarQube 5.6 恢复质量配置文件 [英] SonarQube 5.6 restore quality profile

查看:21
本文介绍了SonarQube 5.6 恢复质量配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 curl 通过 Web API 在全新安装的 SonarQube v.5.6.4 上恢复质量配置文件.

在 c: emp 中,我有一个从运行 Sonar 导出的Sonar way"配置文件,我已将其重命名为 test.xml(在内部,名称也更改为 test,因此两个配置文件都是不同的").

从 c: emp 位置,我使用了以下 curl 命令:

curl -v -X POST -u admin:admin --header "Content-Type: application/xml""http://localhost:9000/api/qualityprofiles/restore" -d 备份=test.xml

回复是:

500 Internal Server Error 如果您是本网站的管理员,那么请阅读此 Web 应用程序的日志文件以找出问题所在.

无论我如何更改 curl 命令(使用不同的内容类型,使用 -F 参数,在文件名前使用 @),​​我都无法解决这个问题.

此外,我检查了声纳日志,如下所示:

2017.01.30 14:13:14 错误 web[rails]/! FAILSAFE/! Mon Jan 30 14:13:14 +0100 2017状态:500 内部服务器错误nil:NilClass 的未定义方法名称"C:/bin/sonarqube-5.6.4/web/WEB-INF/gems/gems/activesupport-2.3.15/lib/active_support/xml_mini/rexml.rb:29:in `merge_element!'C:/bin/sonarqube-5.6.4/web/WEB-INF/gems/gems/activesupport-2.3.15/lib/active_support/xml_mini/rexml.rb:18:in `parse'org/jruby/RubyKernel.java:2227:in `send'C:1:在解析"中C:/bin/sonarqube-5.6.4/web/WEB-INF/gems/gems/activesupport-2.3.15/lib/active_support/core_ext/hash/conversions.rb:171:in `from_xml'C:/bin/sonarqube-5.6.4/web/WEB-INF/gems/gems/actionpack-2.3.15/lib/action_controller/params_parser.rb:34:in `parse_formatted_pa​​rameters'C:/bin/sonarqube-5.6.4/web/WEB-INF/gems/gems/actionpack-2.3.15/lib/action_controller/params_parser.rb:11:in `call'文件:/C:/bin/sonarqube-5.6.4/lib/server/jruby-rack-1.1.13.2.jar!/jruby/rack/session_store.rb:70:in `context'C:/bin/sonarqube-5.6.4/web/WEB-INF/gems/gems/rack-1.1.6/lib/rack/session/abstract/id.rb:58:in `call'C:/bin/sonarqube-5.6.4/web/WEB-INF/gems/gems/actionpack-2.3.15/lib/action_controller/failsafe.rb:26:in `call'C:/bin/sonarqube-5.6.4/web/WEB-INF/gems/gems/actionpack-2.3.15/lib/action_controller/dispatcher.rb:106:in `call'文件:/C:/bin/sonarqube-5.6.4/lib/server/jruby-rack-1.1.13.2.jar!/rack/adapter/rails.rb:34:in `serve_rails'文件:/C:/bin/sonarqube-5.6.4/lib/server/jruby-rack-1.1.13.2.jar!/rack/adapter/rails.rb:39:in `call'file:/C:/bin/sonarqube-5.6.4/lib/server/jruby-rack-1.1.13.2.jar!/rack/handler/servlet.rb:22:in `call'

5.6.4 版有问题吗?

提前感谢您的任何反馈.

解决方案

我的问题的答案是这个命令:

curl -v POST -u admin:admin "http://localhost:9000/api/qualityprofiles/restore"--form backup=@test.xml

这个组合好像没试过.

响应为 200 OK:

<上一页>HTTP/1.1 100 继续HTTP/1.1 200 正常服务器:Apache-Coyote/1.1设置 Cookie:JSESSIONID=A20898D27A0D843EEC6ED9791CABEB49;路径=/;HttpOnlyX-运行时:265ETag:7cce49c3a8a16a16c8c48cc4942df042"缓存控制:无缓存、无存储、必须重新验证X 框架选项:SAMEORIGINX-XSS-防护:1;模式=块X-Content-Type-Options: nosniff内容类型:application/json;charset=utf-8内容长度:166日期:2017 年 1 月 30 日星期一 14:19:51 GMT

I am trying to restore a quality profile on a fresh installation of SonarQube v.5.6.4 over Web API using curl.

In c: emp I have an exported "Sonar way" profile from running Sonar and I have renamed it to test.xml (inside, the name was also changed to test so that both profiles are "different").

From the c: emp location, I used the following curl command:

curl -v -X POST -u admin:admin --header "Content-Type: application/xml"
     "http://localhost:9000/api/qualityprofiles/restore" -d backup=test.xml

The response was:

500 Internal Server Error If you are the administrator of this website, 
then please read this web application's log file to find out what went wrong.

No matter how I changed the curl-command (with different content-types, with -F paramter, with @ before file name), I could not manage to fix this problem.

Moreover, I checked Sonar logs which look like this:

2017.01.30 14:13:14 ERROR web[rails] /! FAILSAFE /!  Mon Jan 30 14:13:14 +0100 2017
  Status: 500 Internal Server Error
  undefined method `name' for nil:NilClass
    C:/bin/sonarqube-5.6.4/web/WEB-INF/gems/gems/activesupport-2.3.15/lib/active_support/xml_mini/rexml.rb:29:in `merge_element!'
    C:/bin/sonarqube-5.6.4/web/WEB-INF/gems/gems/activesupport-2.3.15/lib/active_support/xml_mini/rexml.rb:18:in `parse'
    org/jruby/RubyKernel.java:2227:in `send'
    C:1:in `parse'
    C:/bin/sonarqube-5.6.4/web/WEB-INF/gems/gems/activesupport-2.3.15/lib/active_support/core_ext/hash/conversions.rb:171:in `from_xml'
    C:/bin/sonarqube-5.6.4/web/WEB-INF/gems/gems/actionpack-2.3.15/lib/action_controller/params_parser.rb:34:in `parse_formatted_parameters'
    C:/bin/sonarqube-5.6.4/web/WEB-INF/gems/gems/actionpack-2.3.15/lib/action_controller/params_parser.rb:11:in `call'
    file:/C:/bin/sonarqube-5.6.4/lib/server/jruby-rack-1.1.13.2.jar!/jruby/rack/session_store.rb:70:in `context'
    C:/bin/sonarqube-5.6.4/web/WEB-INF/gems/gems/rack-1.1.6/lib/rack/session/abstract/id.rb:58:in `call'
    C:/bin/sonarqube-5.6.4/web/WEB-INF/gems/gems/actionpack-2.3.15/lib/action_controller/failsafe.rb:26:in `call'
    C:/bin/sonarqube-5.6.4/web/WEB-INF/gems/gems/actionpack-2.3.15/lib/action_controller/dispatcher.rb:106:in `call'
    file:/C:/bin/sonarqube-5.6.4/lib/server/jruby-rack-1.1.13.2.jar!/rack/adapter/rails.rb:34:in `serve_rails'
    file:/C:/bin/sonarqube-5.6.4/lib/server/jruby-rack-1.1.13.2.jar!/rack/adapter/rails.rb:39:in `call'
    file:/C:/bin/sonarqube-5.6.4/lib/server/jruby-rack-1.1.13.2.jar!/rack/handler/servlet.rb:22:in `call'

Is there something wrong with version 5.6.4?

Thanks in advance for any feedback.

解决方案

The answer to my problem was this command:

curl -v POST -u admin:admin "http://localhost:9000/api/qualityprofiles/restore"  
--form backup=@test.xml

It looks like I didn't try this combination before.

The response was 200 OK:

 HTTP/1.1 100 Continue
 HTTP/1.1 200 OK
 Server: Apache-Coyote/1.1
 Set-Cookie: JSESSIONID=A20898D27A0D843EEC6ED9791CABEB49; Path=/; HttpOnly
 X-Runtime: 265
 ETag: "7cce49c3a8a16a16c8c48cc4942df042"
 Cache-Control: no-cache, no-store, must-revalidate
 X-Frame-Options: SAMEORIGIN
 X-XSS-Protection: 1; mode=block
 X-Content-Type-Options: nosniff
 Content-Type: application/json;charset=utf-8
 Content-Length: 166
 Date: Mon, 30 Jan 2017 14:19:51 GMT

这篇关于SonarQube 5.6 恢复质量配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆