Method: Stax::Cmd::Codebuild#tail

Defined in:
lib/stax/mixin/codebuild.rb

#tail(id = nil) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/stax/mixin/codebuild.rb', line 90

def tail(id = nil)
  trap('SIGINT', 'EXIT')    # clean exit with ctrl-c
  id ||= Aws::Codebuild.builds_for_project(my.stack_project_names.first, 1).first
  debug("Phases for build #{id}")
  seen = {}
  loop do
    (Aws::Codebuild.builds([id]).first.phases || []).each do |p|
      i = p.phase_type + p.phase_status.to_s
      print_phase(p) unless seen[i]
      seen[i] = true
    end
    break if seen['COMPLETED']
    sleep(3)
  end
end