Class: Hudson::HudsonBase
- Inherits:
-
Object
- Object
- Hudson::HudsonBase
- Defined in:
- lib/hudson-api.rb
Overview
Base class for all Hudson objects
Direct Known Subclasses
Class Method Summary collapse
Class Method Details
.send_post_request(url, data = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/hudson-api.rb', line 26 def self.send_post_request(url, data={}) uri = URI.parse(url) http = Net::HTTP.new(uri.host, uri.port) request = Net::HTTP::Post.new(uri.request_uri) request.basic_auth(Hudson[:user], Hudson[:password]) if Hudson[:user] and Hudson[:password] request.add_field "Content-Type", "application/xml" request.set_form_data(data) response = http.request(request) response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection) end |
.send_xml_post_request(url, xml) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/hudson-api.rb', line 37 def self.send_xml_post_request(url, xml) uri = URI.parse(url) http = Net::HTTP.new(uri.host, uri.port) request = Net::HTTP::Post.new(uri.request_uri) request.basic_auth(Hudson[:user], Hudson[:password]) if Hudson[:user] and Hudson[:password] request.add_field "Content-Type", "application/xml" request.body = xml response = http.request(request) response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection) end |