Class: LeeroyJenkins::JobFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/leeroy_jenkins/job_finder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(jenkins_client) ⇒ JobFinder

Returns a new instance of JobFinder.



5
6
7
# File 'lib/leeroy_jenkins/job_finder.rb', line 5

def initialize(jenkins_client)
  @jenkins_client = jenkins_client
end

Instance Attribute Details

#jenkins_clientObject (readonly)

Returns the value of attribute jenkins_client.



3
4
5
# File 'lib/leeroy_jenkins/job_finder.rb', line 3

def jenkins_client
  @jenkins_client
end

Instance Method Details

#find_jobs(regex, job_names = []) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/leeroy_jenkins/job_finder.rb', line 9

def find_jobs(regex, job_names = [])
  jobs_matching_regex = jenkins_client.job.list(regex)

  if job_names.any?
    jobs_matching_regex.select do |job|
      job_names.include? job
    end
  else
    jobs_matching_regex
  end
end