class Codebuild::Project

Attributes

full_project_name[R]
project_name[R]
project_path[R]

Public Class Methods

new(options={}) click to toggle source
# File lib/codebuild/project.rb, line 10
def initialize(options={})
  @options = options
  @project_name = options[:project_name]
  @full_project_name = options[:full_project_name] # includes -development at the end
  @project_path = options[:project_path] || get_project_path
  @properties = default_properties # defaults make project.rb simpler
end

Public Instance Methods

build_spec() click to toggle source
# File lib/codebuild/project.rb, line 68
def build_spec
  lookup_codebuild_file("buildspec.yml")
end
default_properties() click to toggle source
# File lib/codebuild/project.rb, line 34
def default_properties
  {
    name: @full_project_name,
    description: @full_project_name,
    artifacts: { type: "NO_ARTIFACTS" },
    service_role: { ref: "IamRole" },
    badge_enabled: true,
    timeout_in_minutes: 20,
    logs_config: {
      cloud_watch_logs: {
        status: "ENABLED",
        # the default log group name is thankfully the project name
      }
    },
    source: {
      type: "GITHUB",
      # location: "", # required
      # git_clone_depth: 1,
      git_submodules_config: { fetch_submodules: true },
      build_spec: build_spec,
      # auth doesnt seem to work, refer to https://github.com/tongueroo/codebuild/blob/master/readme/github_oauth.md
      # auth: {
      #   type: "OAUTH",
      #   # resource: "", # required
      # },
      report_build_status: true,
    }
  }
end
exist?() click to toggle source
# File lib/codebuild/project.rb, line 18
def exist?
  File.exist?(@project_path)
end
get_project_path() click to toggle source
# File lib/codebuild/project.rb, line 64
def get_project_path
  lookup_codebuild_file("project.rb")
end
run() click to toggle source
# File lib/codebuild/project.rb, line 22
def run
  load_variables
  evaluate(@project_path)
  resource = {
    code_build: {
      type: "AWS::CodeBuild::Project",
      properties: @properties
    }
  }
  CfnCamelizer.transform(resource)
end