Class: RoboPigeon::Jenkins::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/robopigeon/jenkins/job.rb

Constant Summary collapse

DEFAULT_START_TIMEOUT =

45 minutes

(45 * 60)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeJob

Returns a new instance of Job.



6
7
8
9
10
11
12
13
14
# File 'lib/robopigeon/jenkins/job.rb', line 6

def initialize
  self.build_timeout = 60 * 60 # 60 minutes in seconds
  self.params = {}
  self.poll_interval = 10
  self.build_opts = {
    'build_start_timeout' => DEFAULT_START_TIMEOUT,
    'cancel_on_build_start_timeout' => true
  }
end

Instance Attribute Details

#build_optsObject

Returns the value of attribute build_opts.



5
6
7
# File 'lib/robopigeon/jenkins/job.rb', line 5

def build_opts
  @build_opts
end

#build_timeoutObject

Returns the value of attribute build_timeout.



5
6
7
# File 'lib/robopigeon/jenkins/job.rb', line 5

def build_timeout
  @build_timeout
end

#jidObject

Returns the value of attribute jid.



5
6
7
# File 'lib/robopigeon/jenkins/job.rb', line 5

def jid
  @jid
end

#logsObject

Returns the value of attribute logs.



5
6
7
# File 'lib/robopigeon/jenkins/job.rb', line 5

def logs
  @logs
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/robopigeon/jenkins/job.rb', line 5

def name
  @name
end

#paramsObject

Returns the value of attribute params.



5
6
7
# File 'lib/robopigeon/jenkins/job.rb', line 5

def params
  @params
end

#poll_intervalObject

Returns the value of attribute poll_interval.



5
6
7
# File 'lib/robopigeon/jenkins/job.rb', line 5

def poll_interval
  @poll_interval
end

Instance Method Details

#build_and_watch!Object



28
29
30
31
32
33
# File 'lib/robopigeon/jenkins/job.rb', line 28

def build_and_watch!
  self.jid = client.job.build(name, params.to_h, build_opts)
  puts "Created jenkins job: #{job_url(jid)}"

  watch_build
end

#clientObject



16
17
18
# File 'lib/robopigeon/jenkins/job.rb', line 16

def client
  RoboPigeon::Jenkins::Client.client
end

#job_url(jid) ⇒ Object



24
25
26
# File 'lib/robopigeon/jenkins/job.rb', line 24

def job_url(jid)
  "#{RoboPigeon::Jenkins::Client.url}/jobs/#{name}/#{jid}"
end

#start_timeout=(timeout) ⇒ Object



20
21
22
# File 'lib/robopigeon/jenkins/job.rb', line 20

def start_timeout=(timeout)
  build_opts['build_start_timeout'] = timeout
end