Module: Hudson

Defined in:
lib/hudson-remote-api.rb,
lib/hudson-remote-api/job.rb,
lib/hudson-remote-api/build.rb,
lib/hudson-remote-api/config.rb,
lib/hudson-remote-api/errors.rb,
lib/hudson-remote-api/multicast.rb,
lib/hudson-remote-api/build_queue.rb

Class Method Summary (collapse)

Class Method Details

+ (Object) [](param)



7
8
9
# File 'lib/hudson-remote-api/config.rb', line 7

def self.[](param)
  return @@settings[param]
end

+ (Object) []=(param, value)



11
12
13
14
15
16
17
18
19
20
# File 'lib/hudson-remote-api/config.rb', line 11

def self.[]=(param,value)
  param = param.to_sym if param.kind_of?(String)
  if param == :host or param == :url
    value = "http://#{value}" if value !~ /https?:\/\//
    @@settings[:url] = value
  else
    @@settings[param]=value
  end
  HudsonObject::load_xml_api
end

+ (Object) auto_config

Discovers nearby Hudson server on the network and configures settings



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/hudson-remote-api/config.rb', line 31

def self.auto_config
  xml_response = discover()
  if xml_response
    #puts xml_response
    doc = REXML::Document.new(xml_response)
    url = doc.elements["/hudson/url"]
    if url
      Hudson[:url] = url.text
      Hudson[:version] = doc.elements["/hudson/version"].text
      puts "found Hudson version #{Hudson[:version]} @ #{Hudson[:url]}"
      return true
    end
  end
end

+ (Object) discover(multicast_addr = "239.77.124.213",, port = 33848, timeout_limit = 5)



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/hudson-remote-api/multicast.rb', line 6

def self.discover(multicast_addr = "239.77.124.213", port=33848, timeout_limit=5)
  socket = UDPSocket.open
  socket.setsockopt(Socket::IPPROTO_IP, Socket::IP_TTL, [1].pack('i'))
  socket.send(ARGV.join(' '), 0, multicast_addr, port)
  msg = nil
  #msg, info = socket.recvfrom_nonblock(1024)
  timeout(timeout_limit) do
    msg, info = socket.recvfrom(1024)
  end
  msg
rescue Exception => e
  puts e
  nil
ensure
  socket.close 
end

+ (Object) settings=(settings)



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

def self.settings=(settings)
  if settings.kind_of?(Hash)
    settings.each do |param, value|
      Hudson[param] = value
    end
  end
end