Sha256: 5b5eb1cdbd076036d28e966394f6bf7a34c8ab1a2b64f96341180b7204d0434e
Contents?: true
Size: 1.63 KB
Versions: 3
Compression:
Stored size: 1.63 KB
Contents
module Codebuild class Start include AwsServices def initialize(options) @options = options @project_name = options[:project_name] || inferred_project_name @full_project_name = project_name_convention(@project_name) end def run source_version = @options[:branch] || @options[:source_version] || 'master' resp = codebuild.start_build( project_name: project_name, source_version: source_version ) puts "Build started for project: #{project_name}" puts "Please check the CodeBuild console for the status." puts "Codebuild Log Url:" puts codebuild_log_url(resp.build.id) end def project_name if project_exists?(@full_project_name) @full_project_name elsif stack_exists?(@project_name) # allow `cb start STACK_NAME` to work too resp = cfn.describe_stack_resources(stack_name: @project_name) resource = resp.stack_resources.find do |r| r.logical_resource_id == "CodeBuild" end resource.physical_resource_id # codebuild project name else puts "ERROR: Unable to find the codebuild project with identifier #@identifier".color(:red) exit 1 end end private def codebuild_log_url(build_id) build_id = build_id.split(':').last region = `aws configure get region`.strip rescue "us-east-1" "https://#{region}.console.aws.amazon.com/codesuite/codebuild/projects/#{project_name}/build/#{project_name}%3A#{build_id}/log" end def project_exists?(name) resp = codebuild.batch_get_projects(names: [name]) resp.projects.size > 0 end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
codebuild-0.5.0 | lib/codebuild/start.rb |
codebuild-0.4.0 | lib/codebuild/start.rb |
codebuild-0.3.0 | lib/codebuild/start.rb |