Class: AgileNotifier::Jenkins

Inherits:
CI
  • Object
show all
Extended by:
ResponseHelper
Defined in:
lib/agile_notifier/jenkins.rb

Defined Under Namespace

Classes: Job

Constant Summary collapse

JSON_API =
'/api/json'

Instance Attribute Summary

Attributes inherited from CI

#job

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ResponseHelper

get_value_of_key

Methods inherited from CI

#is_available?, #original_is_available?

Methods included from Servable

#is_available?

Constructor Details

#initialize(url, job_name, build_number = nil) ⇒ Jenkins

Returns a new instance of Jenkins.



18
19
20
21
22
# File 'lib/agile_notifier/jenkins.rb', line 18

def initialize(url, job_name, build_number = nil)
  @url = url
  job_url = URI.encode("#{@url}/job/#{job_name}/")
  @job = Job.new(job_name, job_url, build_number)
end

Class Method Details

.get_value(key, url) ⇒ Object



14
15
16
# File 'lib/agile_notifier/jenkins.rb', line 14

def self.get_value(key, url)
  get_value_of_key(key, url.gsub(/\/$/, '') + JSON_API)
end

Instance Method Details

#get_all_jobsObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/agile_notifier/jenkins.rb', line 24

def get_all_jobs
  jobs = self.class.get_value('jobs', @url)
  if jobs.nil?
    return nil
  else
    jobs.inject([]) do |all_jobs, job|
      all_jobs.push(Job.new(job['name'], job['url']))
    end
  end
end