Class: Civu::Client
- Inherits:
-
Object
- Object
- Civu::Client
- Defined in:
- lib/civu.rb
Instance Attribute Summary collapse
-
#executor ⇒ Object
readonly
Returns the value of attribute executor.
Instance Method Summary collapse
- #clone(view_name) ⇒ Object
-
#initialize(host, uname = nil, pass = nil, debug = false) ⇒ Client
constructor
A new instance of Client.
- #list(view_name) ⇒ Object
Constructor Details
#initialize(host, uname = nil, pass = nil, debug = false) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 13 14 15 |
# File 'lib/civu.rb', line 7 def initialize(host, uname = nil, pass = nil, debug = false) @client = JenkinsApi::Client.new( :server_url => host, :username => uname, :password => pass, :log_level => debug ? Logger::DEBUG : Logger::FATAL ) @executor = Civu::Executor.new end |
Instance Attribute Details
#executor ⇒ Object (readonly)
Returns the value of attribute executor.
6 7 8 |
# File 'lib/civu.rb', line 6 def executor @executor end |
Instance Method Details
#clone(view_name) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/civu.rb', line 29 def clone(view_name) urls = list(view_name) urls.each do |url| @executor.run("git clone #{url} #{url.partition(':').last}") end end |
#list(view_name) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/civu.rb', line 17 def list(view_name) urls = [] jobs = @client.view.list_jobs(view_name) jobs.each do |job| job_xml = @client.job.get_config(job) doc = Nokogiri::XML(job_xml) url_node = doc.xpath('//scm//userRemoteConfigs//hudson.plugins.git.UserRemoteConfig//url') urls << url_node.first.content unless url_node.empty? end urls.uniq end |