CodeBuildStepProps

class aws_cdk.pipelines.CodeBuildStepProps(*, commands, additional_inputs=None, env=None, env_from_cfn_outputs=None, input=None, install_commands=None, primary_output_directory=None, action_role=None, build_environment=None, cache=None, file_system_locations=None, logging=None, partial_build_spec=None, project_name=None, role=None, role_policy_statements=None, security_groups=None, subnet_selection=None, timeout=None, vpc=None)

Bases: ShellStepProps

Construction props for a CodeBuildStep.

Parameters:
  • commands (Sequence[str]) – Commands to run.

  • additional_inputs (Optional[Mapping[str, IFileSetProducer]]) – Additional FileSets to put in other directories. Specifies a mapping from directory name to FileSets. During the script execution, the FileSets will be available in the directories indicated. The directory names may be relative. For example, you can put the main input and an additional input side-by-side with the following configuration:: const script = new pipelines.ShellStep(‘MainScript’, { commands: [‘npm ci’,’npm run build’,’npx cdk synth’], input: pipelines.CodePipelineSource.gitHub(‘org/source1’, ‘main’), additionalInputs: { ‘../siblingdir’: pipelines.CodePipelineSource.gitHub(‘org/source2’, ‘main’), } }); Default: - No additional inputs

  • env (Optional[Mapping[str, str]]) – Environment variables to set. Default: - No environment variables

  • env_from_cfn_outputs (Optional[Mapping[str, CfnOutput]]) – Set environment variables based on Stack Outputs. ``ShellStep``s following stack or stage deployments may access the ``CfnOutput``s of those stacks to get access to –for example–automatically generated resource names or endpoint URLs. Default: - No environment variables created from stack outputs

  • input (Optional[IFileSetProducer]) – FileSet to run these scripts on. The files in the FileSet will be placed in the working directory when the script is executed. Use additionalInputs to download file sets to other directories as well. Default: - No input specified

  • install_commands (Optional[Sequence[str]]) – Installation commands to run before the regular commands. For deployment engines that support it, install commands will be classified differently in the job history from the regular commands. Default: - No installation commands

  • primary_output_directory (Optional[str]) – The directory that will contain the primary output fileset. After running the script, the contents of the given directory will be treated as the primary output of this Step. Default: - No primary output

  • action_role (Optional[IRole]) – Custom execution role to be used for the Code Build Action. Default: - A role is automatically created

  • build_environment (Union[BuildEnvironment, Dict[str, Any], None]) – Changes to environment. This environment will be combined with the pipeline’s default environment. Default: - Use the pipeline’s default build environment

  • cache (Optional[Cache]) – Caching strategy to use. Default: - No cache

  • file_system_locations (Optional[Sequence[IFileSystemLocation]]) – ProjectFileSystemLocation objects for CodeBuild build projects. A ProjectFileSystemLocation object specifies the identifier, location, mountOptions, mountPoint, and type of a file system created using Amazon Elastic File System. Default: - no file system locations

  • logging (Union[LoggingOptions, Dict[str, Any], None]) – Information about logs for CodeBuild projects. A CodeBuild project can create logs in Amazon CloudWatch Logs, an S3 bucket, or both. Default: - no log configuration is set

  • partial_build_spec (Optional[BuildSpec]) – Additional configuration that can only be configured via BuildSpec. You should not use this to specify output artifacts; those should be supplied via the other properties of this class, otherwise CDK Pipelines won’t be able to inspect the artifacts. Set the commands to an empty array if you want to fully specify the BuildSpec using this field. The BuildSpec must be available inline–it cannot reference a file on disk. Default: - BuildSpec completely derived from other properties

  • project_name (Optional[str]) – Name for the generated CodeBuild project. Default: - Automatically generated

  • role (Optional[IRole]) – Custom execution role to be used for the CodeBuild project. Default: - A role is automatically created

  • role_policy_statements (Optional[Sequence[PolicyStatement]]) – Policy statements to add to role used during the synth. Can be used to add acces to a CodeArtifact repository etc. Default: - No policy statements added to CodeBuild Project Role

  • security_groups (Optional[Sequence[ISecurityGroup]]) – Which security group to associate with the script’s project network interfaces. If no security group is identified, one will be created automatically. Only used if ‘vpc’ is supplied. Default: - Security group will be automatically created.

  • subnet_selection (Union[SubnetSelection, Dict[str, Any], None]) – Which subnets to use. Only used if ‘vpc’ is supplied. Default: - All private subnets.

  • timeout (Optional[Duration]) – The number of minutes after which AWS CodeBuild stops the build if it’s not complete. For valid values, see the timeoutInMinutes field in the AWS CodeBuild User Guide. Default: Duration.hours(1)

  • vpc (Optional[IVpc]) – The VPC where to execute the SimpleSynth. Default: - No VPC

ExampleMetadata:

infused

Example:

pipeline = pipelines.CodePipeline(self, "Pipeline",
    synth=pipelines.ShellStep("Synth",
        input=pipelines.CodePipelineSource.connection("my-org/my-app", "main",
            connection_arn="arn:aws:codestar-connections:us-east-1:222222222222:connection/7d2469ff-514a-4e4f-9003-5ca4a43cdc41"
        ),
        commands=["npm ci", "npm run build", "npx cdk synth"]
    ),

    # Turn this on because the pipeline uses Docker image assets
    docker_enabled_for_self_mutation=True
)

pipeline.add_wave("MyWave",
    post=[
        pipelines.CodeBuildStep("RunApproval",
            commands=["command-from-image"],
            build_environment=codebuild.BuildEnvironment(
                # The user of a Docker image asset in the pipeline requires turning on
                # 'dockerEnabledForSelfMutation'.
                build_image=codebuild.LinuxBuildImage.from_asset(self, "Image",
                    directory="./docker-image"
                )
            )
        )
    ]
)

Attributes

action_role

Custom execution role to be used for the Code Build Action.

Default:
  • A role is automatically created

additional_inputs

Additional FileSets to put in other directories.

Specifies a mapping from directory name to FileSets. During the script execution, the FileSets will be available in the directories indicated.

The directory names may be relative. For example, you can put the main input and an additional input side-by-side with the following configuration:

script = pipelines.ShellStep("MainScript",
    commands=["npm ci", "npm run build", "npx cdk synth"],
    input=pipelines.CodePipelineSource.git_hub("org/source1", "main"),
    additional_inputs={
        "../siblingdir": pipelines.CodePipelineSource.git_hub("org/source2", "main")
    }
)
Default:
  • No additional inputs

build_environment

Changes to environment.

This environment will be combined with the pipeline’s default environment.

Default:
  • Use the pipeline’s default build environment

cache

Caching strategy to use.

Default:
  • No cache

commands

Commands to run.

env

Environment variables to set.

Default:
  • No environment variables

env_from_cfn_outputs

Set environment variables based on Stack Outputs.

``ShellStep``s following stack or stage deployments may access the ``CfnOutput``s of those stacks to get access to –for example–automatically generated resource names or endpoint URLs.

Default:
  • No environment variables created from stack outputs

file_system_locations

ProjectFileSystemLocation objects for CodeBuild build projects.

A ProjectFileSystemLocation object specifies the identifier, location, mountOptions, mountPoint, and type of a file system created using Amazon Elastic File System.

Default:
  • no file system locations

input

FileSet to run these scripts on.

The files in the FileSet will be placed in the working directory when the script is executed. Use additionalInputs to download file sets to other directories as well.

Default:
  • No input specified

install_commands

Installation commands to run before the regular commands.

For deployment engines that support it, install commands will be classified differently in the job history from the regular commands.

Default:
  • No installation commands

logging

Information about logs for CodeBuild projects.

A CodeBuild project can create logs in Amazon CloudWatch Logs, an S3 bucket, or both.

Default:
  • no log configuration is set

partial_build_spec

Additional configuration that can only be configured via BuildSpec.

You should not use this to specify output artifacts; those should be supplied via the other properties of this class, otherwise CDK Pipelines won’t be able to inspect the artifacts.

Set the commands to an empty array if you want to fully specify the BuildSpec using this field.

The BuildSpec must be available inline–it cannot reference a file on disk.

Default:
  • BuildSpec completely derived from other properties

primary_output_directory

The directory that will contain the primary output fileset.

After running the script, the contents of the given directory will be treated as the primary output of this Step.

Default:
  • No primary output

project_name

Name for the generated CodeBuild project.

Default:
  • Automatically generated

role

Custom execution role to be used for the CodeBuild project.

Default:
  • A role is automatically created

role_policy_statements

Policy statements to add to role used during the synth.

Can be used to add acces to a CodeArtifact repository etc.

Default:
  • No policy statements added to CodeBuild Project Role

security_groups

Which security group to associate with the script’s project network interfaces.

If no security group is identified, one will be created automatically.

Only used if ‘vpc’ is supplied.

Default:
  • Security group will be automatically created.

subnet_selection

Which subnets to use.

Only used if ‘vpc’ is supplied.

Default:
  • All private subnets.

timeout

The number of minutes after which AWS CodeBuild stops the build if it’s not complete.

For valid values, see the timeoutInMinutes field in the AWS CodeBuild User Guide.

Default:

Duration.hours(1)

vpc

The VPC where to execute the SimpleSynth.

Default:
  • No VPC