19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/codebuild/stack.rb', line 19
def run
options = @options.merge(
project_name: @project_name,
full_project_name: @full_project_name,
)
project_builder = Project.new(options)
unless project_builder.exist?
puts "ERROR: Codebuild project does not exist: #{project_builder.project_path}".color(:red)
exit 1
return
end
project = project_builder.run
@template["Resources"].merge!(project)
if project["CodeBuild"]["Properties"]["ServiceRole"] == {"Ref"=>"IamRole"}
role = Role.new(options).run
@template["Resources"].merge!(role)
end
schedule = Schedule.new(options).run
@template["Resources"].merge!(schedule) if schedule
template_path = "/tmp/codebuild.yml"
FileUtils.mkdir_p(File.dirname(template_path))
IO.write(template_path, YAML.dump(@template))
puts "Generated CloudFormation template at #{template_path.color(:green)}"
return if @options[:noop]
puts "Deploying stack #{@stack_name.color(:green)} with CodeBuild project #{@full_project_name.color(:green)}"
begin
perform
url_info
return unless @options[:wait]
status.wait
exit 2 unless status.success?
rescue Aws::CloudFormation::Errors::ValidationError => e
if e.message.include?("No updates")
puts "WARN: #{e.message}".color(:yellow)
else
puts "ERROR ValidationError: #{e.message}".color(:red)
exit 1
end
end
end
|