BuildSpec

class aws_cdk.aws_codebuild.BuildSpec

Bases: object

BuildSpec for CodeBuild projects.

ExampleMetadata:

infused

Example:

# later:
# project: codebuild.PipelineProject
source_output = codepipeline.Artifact()
build_action = codepipeline_actions.CodeBuildAction(
    action_name="Build1",
    input=source_output,
    project=codebuild.PipelineProject(self, "Project",
        build_spec=codebuild.BuildSpec.from_object({
            "version": "0.2",
            "env": {
                "exported-variables": ["MY_VAR"
                ]
            },
            "phases": {
                "build": {
                    "commands": "export MY_VAR="some value""
                }
            }
        })
    ),
    variables_namespace="MyNamespace"
)
codepipeline_actions.CodeBuildAction(
    action_name="CodeBuild",
    project=project,
    input=source_output,
    environment_variables={
        "MyVar": codebuild.BuildEnvironmentVariable(
            value=build_action.variable("MY_VAR")
        )
    }
)

Methods

abstract to_build_spec()

Render the represented BuildSpec.

Return type:

str

Attributes

is_immediate

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

Static Methods

classmethod from_object(value)
Parameters:

value (Mapping[str, Any]) –

Return type:

BuildSpec

classmethod from_object_to_yaml(value)

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

Parameters:

value (Mapping[str, Any]) – the object containing the buildspec that will be rendered as YAML.

Return type:

BuildSpec

classmethod from_source_filename(filename)

Use a file from the source as buildspec.

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

Parameters:

filename (str) –

Return type:

BuildSpec