Class: WerckerAPI::PipelineRunner
- Inherits:
-
Object
- Object
- WerckerAPI::PipelineRunner
- Defined in:
- lib/wercker_api/pipeline_runner.rb
Defined Under Namespace
Classes: Timeout
Instance Attribute Summary collapse
-
#delay ⇒ Object
Returns the value of attribute delay.
-
#max_attempts ⇒ Object
Returns the value of attribute max_attempts.
Instance Method Summary collapse
-
#initialize(client, max_attempts: 20, delay: 10) ⇒ PipelineRunner
constructor
A new instance of PipelineRunner.
- #run(pipeline_id, trigger_run_params = {}) ⇒ Object
Constructor Details
#initialize(client, max_attempts: 20, delay: 10) ⇒ PipelineRunner
Returns a new instance of PipelineRunner.
27 28 29 30 31 32 |
# File 'lib/wercker_api/pipeline_runner.rb', line 27 def initialize(client, max_attempts: 20, delay: 10) self.client = client self.max_attempts = max_attempts self.delay = delay self.current_attempt = 0 end |
Instance Attribute Details
#delay ⇒ Object
Returns the value of attribute delay.
25 26 27 |
# File 'lib/wercker_api/pipeline_runner.rb', line 25 def delay @delay end |
#max_attempts ⇒ Object
Returns the value of attribute max_attempts.
25 26 27 |
# File 'lib/wercker_api/pipeline_runner.rb', line 25 def max_attempts @max_attempts end |
Instance Method Details
#run(pipeline_id, trigger_run_params = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/wercker_api/pipeline_runner.rb', line 34 def run(pipeline_id, trigger_run_params = {}) run = client.trigger_run pipeline_id, trigger_run_params while %w[running notstarted].include?(run.status) raise Timeout.new(pipeline_id, self) if max_attempt_reached? sleep @delay run = client.run(run.id) STDOUT.puts run.status puts run.status @current_attempt += 1 end run end |