Class: Hudson::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/hudson-remote-api/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_settings = {}) ⇒ Client

Returns a new instance of Client.



14
15
16
17
18
# File 'lib/hudson-remote-api/client.rb', line 14

def initialize(config_settings={})
  @configuration = ::Hudson::Settings.new(config_settings).configuration
  @xml_api = ::Hudson::XmlApi.new(self.configuration)
  fetch_crumb
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



12
13
14
# File 'lib/hudson-remote-api/client.rb', line 12

def configuration
  @configuration
end

#xml_apiObject (readonly)

Returns the value of attribute xml_api.



12
13
14
# File 'lib/hudson-remote-api/client.rb', line 12

def xml_api
  @xml_api
end

Instance Method Details

#auto_configureObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/hudson-remote-api/client.rb', line 20

def auto_configure
  xml_response = ::Hudson.discover
  if xml_response
    mulitcast_parser = ::Hudson::Parser::Multicast.new(xml_response)
    self.configuration.host = mulitcast_parser.url || self.configuration.host
    self.configuration.version = mulitcast_parser.version || self.configuration.version
    puts "found Hudson version #{mulitcast_parser.version} @ #{mulitcast_parser.url}"
    return !mulitcast_parser.url.nil?
  end
end

#build_job!(job_name, delay = 0) ⇒ Object



39
40
41
# File 'lib/hudson-remote-api/client.rb', line 39

def build_job!(job_name, delay=0)
  send_post_request(self.xml_api.build_url(job_name), {:delay => "#{delay}sec"})
end

#build_job_with_parameters!(job_name, params, delay = 0) ⇒ Object



43
44
45
# File 'lib/hudson-remote-api/client.rb', line 43

def build_job_with_parameters!(job_name, params, delay=0)
  send_post_request(self.xml_api.build_with_parameters_url(job_name), {:delay => "#{delay}sec"}.merge(params) )
end

#build_queue_infoObject



35
36
37
# File 'lib/hudson-remote-api/client.rb', line 35

def build_queue_info
  get_xml(self.xml_api.build_queue_info_url)
end

#create_item!(params) ⇒ Object



51
52
53
# File 'lib/hudson-remote-api/client.rb', line 51

def create_item!(params)
  send_post_request(self.xml_api.create_item_url, params)
end

#delete_job!(job_name) ⇒ Object



55
56
57
# File 'lib/hudson-remote-api/client.rb', line 55

def delete_job!(job_name)
  send_post_request(self.xml_api.delete_url(job_name))
end

#disable_job!(job_name) ⇒ Object



59
60
61
# File 'lib/hudson-remote-api/client.rb', line 59

def disable_job!(job_name)
  send_post_request(self.xml_api.disable_url(job_name))
end

#enable_job!(job_name) ⇒ Object



63
64
65
# File 'lib/hudson-remote-api/client.rb', line 63

def enable_job!(job_name)
  send_post_request(self.xml_api.enable_url(job_name))
end

#job_build_info(job_name, build_number) ⇒ Object



31
32
33
# File 'lib/hudson-remote-api/client.rb', line 31

def job_build_info(job_name, build_number)
  get_xml(self.xml_api.build_info_url(job_name, build_number))
end

#job_config_info(job_name) ⇒ Object



47
48
49
# File 'lib/hudson-remote-api/client.rb', line 47

def job_config_info(job_name)
  get_xml(self.xml_api.job_config_url(job_name))
end

#job_info(job_name) ⇒ Object



67
68
69
# File 'lib/hudson-remote-api/client.rb', line 67

def job_info(job_name)
  get_xml(self.xml_api.job_info_url(job_name))
end

#server_infoObject



71
72
73
# File 'lib/hudson-remote-api/client.rb', line 71

def server_info
  get_xml(self.xml_api.server_info_url)
end

#update_job_config!(job_name, config) ⇒ Object



75
76
77
# File 'lib/hudson-remote-api/client.rb', line 75

def update_job_config!(job_name, config)
  send_xml_post_request(self.xml_api.job_config_url(job_name), config)
end

#wipeout_job_workspace!(job_name) ⇒ Object



79
80
81
# File 'lib/hudson-remote-api/client.rb', line 79

def wipeout_job_workspace!(job_name)
  send_post_request(self.xml_api.wipeout_workspace_url(job_name))
end