Class: Stax::Cmd::Codebuild
Constant Summary
collapse
- COLORS =
{
SUCCEEDED: :green,
FAILED: :red,
FAULT: :red,
CLIENT_ERROR: :red,
STOPPED: :red,
}
Instance Method Summary
collapse
Methods inherited from SubCommand
#info, stax_info, stax_info_tasks
Instance Method Details
#builds ⇒ Object
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/stax/mixin/codebuild.rb', line 48
def builds
my.stack_project_names.each do |project|
debug("Builds for #{project}")
ids = Aws::Codebuild.builds_for_project(project, options[:number])
print_table Aws::Codebuild.builds(ids).map { |b|
duration = human_time_diff(b.end_time - b.start_time)
[b.id, b.initiator, color(b.build_status, COLORS), duration, b.end_time]
}
end
end
|
#phases(id = nil) ⇒ Object
60
61
62
63
64
|
# File 'lib/stax/mixin/codebuild.rb', line 60
def phases(id = nil)
id ||= Aws::Codebuild.builds_for_project(my.stack_project_names.first, 1).first
debug("Phases for build #{id}")
Aws::Codebuild.builds([id]).first.phases.each(&method(:print_phase))
end
|
#projects ⇒ Object
40
41
42
43
44
|
# File 'lib/stax/mixin/codebuild.rb', line 40
def projects
print_table Aws::Codebuild.projects(my.stack_project_names).map { |p|
[p.name, p.source.location, p.environment.image, p.environment.compute_type, p.last_modified]
}
end
|
#start ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/stax/mixin/codebuild.rb', line 86
def start
project = options[:project] || my.stack_project_names.first
version = options[:version] || Git.sha
debug("Starting build for #{project} #{version}")
build = Aws::Codebuild.start(
project_name: project,
source_version: version,
)
puts build.id
tail build.id
end
|
#tail(id = nil) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/stax/mixin/codebuild.rb', line 67
def tail(id = nil)
trap('SIGINT', 'EXIT') 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
|