Class: Jets::CLI::Ci::Base
- Inherits:
-
Base
- Object
- Base
- Jets::CLI::Ci::Base
show all
- Defined in:
- lib/jets/cli/ci/base.rb
Instance Attribute Summary
Attributes inherited from Base
#options
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #paginate, #paging_params, rescue_api_error
#log
#apigateway, #aws_options, #cfn, #codebuild, #dynamodb, #lambda_client, #logs, #s3, #s3_resource, #sns, #sqs, #ssm, #sts, #wafv2
#output_value, #stack_exists?
included, #reset_cache!
Methods included from Api
#api, #api_key
Instance Method Details
#build_id ⇒ Object
28
29
30
31
|
# File 'lib/jets/cli/ci/base.rb', line 28
def build_id
return @options[:build_id] if @options[:build_id]
find_build
end
|
#check_build_id! ⇒ Object
42
43
44
45
46
|
# File 'lib/jets/cli/ci/base.rb', line 42
def check_build_id!
return if build_id
puts "WARN: No builds found for #{project_name.color(:green)} project"
exit
end
|
#find_build ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/jets/cli/ci/base.rb', line 34
def find_build
resp = codebuild.list_builds_for_project(project_name: project_name)
resp.ids.first rescue Aws::CodeBuild::Errors::ResourceNotFoundException => e
logger.error "ERROR: #{e.class} #{e.message}".color(:red)
exit 1
end
|
#run_with_exception_handling ⇒ Object
8
9
10
11
12
13
14
15
|
# File 'lib/jets/cli/ci/base.rb', line 8
def run_with_exception_handling
yield
rescue Aws::CodeBuild::Errors::ResourceNotFoundException => e
puts "ERROR: #{e.class}: #{e.message}".color(:red)
puts "CodeBuild project #{project_name} not found."
rescue Aws::CodeBuild::Errors::InvalidInputException => e
puts "ERROR: #{e.class}: #{e.message}".color(:red)
end
|
#show_console_log_url(build_id) ⇒ Object
48
49
50
51
52
|
# File 'lib/jets/cli/ci/base.rb', line 48
def show_console_log_url(build_id)
log.info "Console Log Url:"
build_id = build_id.split(":").last
log.info "https://#{Jets.aws.region}.console.aws.amazon.com/codesuite/codebuild/projects/#{project_name}/build/#{project_name}%3A#{build_id}/log"
end
|
#stack_name ⇒ Object
Also known as:
project_name
3
4
5
|
# File 'lib/jets/cli/ci/base.rb', line 3
def stack_name
"#{Jets.project.namespace}-ci"
end
|
#stop_build ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/jets/cli/ci/base.rb', line 17
def stop_build
build = codebuild.batch_get_builds(ids: [build_id]).builds.first
if build.build_status == "IN_PROGRESS"
codebuild.stop_build(id: build_id)
true
else
log.info "Not in progress. Status is #{build.build_status}. Cannot stop: #{build_id}"
false
end
end
|