我正在尝试使用curl 通过 Web API 恢复全新安装的 SonarQube v.5.6.4 的质量配置文件。
在 c:\temp 中,我有一个从运行 Sonar 导出的“Sonar way”配置文件,我已将其重命名为 test.xml(在内部,名称也更改为 test,以便两个配置文件“不同”)。
从 c:\temp 位置,我使用了以下curl 命令:
curl -v -X POST -u admin:admin --header "Content-Type: application/xml" "http://localhost:9000/api/qualityprofiles/restore" -d backup=test.xml
回应是:
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.
无论我如何更改curl命令(使用不同的内容类型,使用-F参数,在文件名前添加@),我都无法解决这个问题。
此外,我检查了 Sonar 日志,如下所示:
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'
5.6.4版本有问题吗?
预先感谢您的任何反馈。
最佳答案
我的问题的答案是这个命令:
curl -v POST -u admin:admin "http://localhost:9000/api/qualityprofiles/restore" --form [email protected]
看来我以前没有尝试过这个组合。
响应为 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
关于curl - SonarQube 5.6 恢复质量配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41936962/