aws-cdk-lib.aws_codebuild.BuildSpec

class BuildSpec

LanguageType name
.NETAmazon.CDK.AWS.CodeBuild.BuildSpec
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awscodebuild#BuildSpec
Javasoftware.amazon.awscdk.services.codebuild.BuildSpec
Pythonaws_cdk.aws_codebuild.BuildSpec
TypeScript (source)aws-cdk-lib » aws_codebuild » BuildSpec

Obtainable from LinuxArmBuildImage.runScriptBuildspec(), LinuxBuildImage.runScriptBuildspec(), LinuxGpuBuildImage.runScriptBuildspec(), WindowsBuildImage.runScriptBuildspec()

BuildSpec for CodeBuild projects.

Example

import * as codebuild from 'aws-cdk-lib/aws-codebuild';

const codebuildProject = new codebuild.Project(this, 'Project', {
  projectName: 'MyTestProject',
  buildSpec: codebuild.BuildSpec.fromObject({
    version: '0.2',
    phases: {
      build: {
        commands: [
          'echo "Hello, CodeBuild!"',
        ],
      },
    },
  }),
});

const task = new tasks.CodeBuildStartBuild(this, 'Task', {
  project: codebuildProject,
  integrationPattern: sfn.IntegrationPattern.RUN_JOB,
  environmentVariablesOverride: {
    ZONE: {
      type: codebuild.BuildEnvironmentVariableType.PLAINTEXT,
      value: sfn.JsonPath.stringAt('$.envVariables.zone'),
    },
  },
});

Initializer

new BuildSpec()

Properties

NameTypeDescription
isImmediatebooleanWhether the buildspec is directly available or deferred until build-time.

isImmediate

Type: boolean

Whether the buildspec is directly available or deferred until build-time.

Methods

NameDescription
toBuildSpec(scope?)Render the represented BuildSpec.
static fromAsset(path)Use the contents of a local file as the build spec string.
static fromObject(value)
static fromObjectToYaml(value)Create a buildspec from an object that will be rendered as YAML in the resulting CloudFormation template.
static fromSourceFilename(filename)Use a file from the source as buildspec.

toBuildSpec(scope?)

public toBuildSpec(scope?: Construct): string

Parameters

  • scope Construct

Returns

  • string

Render the represented BuildSpec.


static fromAsset(path)

public static fromAsset(path: string): BuildSpec

Parameters

  • path string

Returns

  • BuildSpec

Use the contents of a local file as the build spec string.

Use this if you have a local .yml or .json file that you want to use as the buildspec


static fromObject(value)

public static fromObject(value: { [string]: any }): BuildSpec

Parameters

  • value { [string]: any }

Returns

  • BuildSpec

static fromObjectToYaml(value)

public static fromObjectToYaml(value: { [string]: any }): BuildSpec

Parameters

  • value { [string]: any } — the object containing the buildspec that will be rendered as YAML.

Returns

  • BuildSpec

Create a buildspec from an object that will be rendered as YAML in the resulting CloudFormation template.


static fromSourceFilename(filename)

public static fromSourceFilename(filename: string): BuildSpec

Parameters

  • filename string

Returns

  • BuildSpec

Use a file from the source as buildspec.

Use this if you want to use a file different from 'buildspec.yml'`