From b3a7ceda0744ddca91dc61657fc127d67d65911e Mon Sep 17 00:00:00 2001 From: Ryan Sandridge Date: Thu, 11 Mar 2021 12:01:39 -0500 Subject: [PATCH] Stop tailing codepipeline when steady state. --- lib/stax/mixin/codepipeline.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/stax/mixin/codepipeline.rb b/lib/stax/mixin/codepipeline.rb index 9c9c82e..fbb8865 100644 --- a/lib/stax/mixin/codepipeline.rb +++ b/lib/stax/mixin/codepipeline.rb @@ -111,6 +111,7 @@ def tail(name = nil) name ||= my.stack_pipeline_names.first last_seen = nil loop do + sleep 5 state = Aws::Codepipeline.state(name) now = Time.now stages = state.stage_states.map do |s| @@ -120,7 +121,14 @@ def tail(name = nil) [s.stage_name, color(s&.latest_execution&.status || '', COLORS), "#{ago} ago", revisions].join(' ') end puts [set_color(now, :blue), stages].flatten.join(' ') - sleep 5 + if stages.none? { |stage| stage.match? /InProgress/ } + if stages.all? { |stage| stage.match? /Succeeded/ } + puts set_color("All stages succeeded!", :green) + else + puts set_color("Pipeline did not complete successfully.", :red) + end + break + end end end