Reputation: 125
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:\temp 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:\temp 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.
Upvotes: 3
Views: 2311
Reputation: 117
If you have all your xml backup files in a single directory, you can restore all of them using only one command in this way :
C:>for /R . %1 IN (*.xml) DO curl.exe -v -X POST -u admin:admin_password
"http://your_server:9000/sonar/api/qualityprofiles/restore" --form backup=@%1
Cheers
Massimo
Upvotes: 1
Reputation: 125
The answer to my problem was this command:
curl -v POST -u admin:admin "http://localhost:9000/api/qualityprofiles/restore" --form [email protected]
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
Upvotes: 4