Skip to content
v2.274.0

CodeBuildStepProps Struct ​

Construction props for a CodeBuildStep.

Example ​

ts
const pipeline = new pipelines.CodePipeline(this, 'Pipeline', {
  synth: new pipelines.ShellStep('Synth', {
    input: pipelines.CodePipelineSource.connection('my-org/my-app', 'main', {
      connectionArn:
        'arn:aws:codestar-connections:us-east-1:222222222222:connection/7d2469ff-514a-4e4f-9003-5ca4a43cdc41', // Created using the AWS console * });',
    }),
    commands: ['npm ci', 'npm run build', 'npx cdk synth'],
  }),

  // Turn this on because the pipeline uses Docker image assets
  dockerEnabledForSelfMutation: true,
});

pipeline.addWave('MyWave', {
  post: [
    new pipelines.CodeBuildStep('RunApproval', {
      commands: ['command-from-image'],
      buildEnvironment: {
        // The user of a Docker image asset in the pipeline requires turning on
        // 'dockerEnabledForSelfMutation'.
        buildImage: codebuild.LinuxBuildImage.fromAsset(this, 'Image', {
          directory: './docker-image',
        }),
      },
    }),
  ],
});

Properties ​

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

Default: A role is automatically created

additionalInputsoptional{ [key: string]: IFileSetProducer }additional_inputsoptionaltyping.Mapping[str, IFileSetProducer]additionalInputsoptionalMap<String, IFileSetProducer>AdditionalInputsoptionalIDictionary<string, IFileSetProducer>AdditionalInputsoptional*map[string]IFileSetProducer#
Additional FileSets to put in other directories.

Default: No additional inputs

notes

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:

ts
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'),
  }
});
buildEnvironmentoptionalBuildEnvironmentbuild_environmentoptionalBuildEnvironmentbuildEnvironmentoptionalBuildEnvironmentBuildEnvironmentoptionalBuildEnvironmentBuildEnvironmentoptionalBuildEnvironment#
Changes to environment.

Default: Use the pipeline's default build environment

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

cacheoptionalCachecacheoptionalCachecacheoptionalCacheCacheoptionalCacheCacheoptionalCache#
Caching strategy to use.

Default: No cache

commandsstring[]commandstyping.List[str]commandsList<String>Commandsstring[]Commands*[]*stringrequired#
Commands to run.
envoptional{ [key: string]: string }envoptionaltyping.Mapping[str, str]envoptionalMap<String, String>EnvoptionalIDictionary<string, string>Envoptional*map[string]*string#
Environment variables to set.

Default: No environment variables

envFromCfnOutputsoptional{ [key: string]: CfnOutput }env_from_cfn_outputsoptionaltyping.Mapping[str, CfnOutput]envFromCfnOutputsoptionalMap<String, CfnOutput>EnvFromCfnOutputsoptionalIDictionary<string, CfnOutput>EnvFromCfnOutputsoptional*map[string]CfnOutput#
Set environment variables based on Stack Outputs.

Default: No environment variables created from stack outputs

ShellSteps following stack or stage deployments may access the CfnOutputs of those stacks to get access to --for example--automatically generated resource names or endpoint URLs.

fileSystemLocationsoptionalIFileSystemLocation[]file_system_locationsoptionaltyping.List[IFileSystemLocation]fileSystemLocationsoptionalList<IFileSystemLocation>FileSystemLocationsoptionalIFileSystemLocation[]FileSystemLocationsoptional*[]IFileSystemLocation#
ProjectFileSystemLocation objects for CodeBuild build projects.

Default: no file system locations

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

inputoptionalIFileSetProducerinputoptionalIFileSetProducerinputoptionalIFileSetProducerInputoptionalIFileSetProducerInputoptionalIFileSetProducer#
FileSet to run these scripts on.

Default: No input specified

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.

installCommandsoptionalstring[]install_commandsoptionaltyping.List[str]installCommandsoptionalList<String>InstallCommandsoptionalstring[]InstallCommandsoptional*[]*string#
Installation commands to run before the regular commands.

Default: No installation commands

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

loggingoptionalLoggingOptionsloggingoptionalLoggingOptionsloggingoptionalLoggingOptionsLoggingoptionalLoggingOptionsLoggingoptionalLoggingOptions#
Information about logs for CodeBuild projects.

Default: no log configuration is set

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

partialBuildSpecoptionalBuildSpecpartial_build_specoptionalBuildSpecpartialBuildSpecoptionalBuildSpecPartialBuildSpecoptionalBuildSpecPartialBuildSpecoptionalBuildSpec#
Additional configuration that can only be configured via BuildSpec.

Default: BuildSpec completely derived from other properties

notes

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.

primaryOutputDirectoryoptionalstringprimary_output_directoryoptionalstrprimaryOutputDirectoryoptionalStringPrimaryOutputDirectoryoptionalstringPrimaryOutputDirectoryoptional*string#
The directory that will contain the primary output fileset.

Default: No primary output

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

projectNameoptionalstringproject_nameoptionalstrprojectNameoptionalStringProjectNameoptionalstringProjectNameoptional*string#
Name for the generated CodeBuild project.

Default: Automatically generated

roleoptionalIRoleroleoptionalIRoleroleoptionalIRoleRoleoptionalIRoleRoleoptionalIRole#
Custom execution role to be used for the CodeBuild project.

Default: A role is automatically created

rolePolicyStatementsoptionalPolicyStatement[]role_policy_statementsoptionaltyping.List[PolicyStatement]rolePolicyStatementsoptionalList<PolicyStatement>RolePolicyStatementsoptionalPolicyStatement[]RolePolicyStatementsoptional*[]PolicyStatement#
Policy statements to add to role used during the synth.

Default: No policy statements added to CodeBuild Project Role

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

securityGroupsoptionalISecurityGroup[]security_groupsoptionaltyping.List[ISecurityGroup]securityGroupsoptionalList<ISecurityGroup>SecurityGroupsoptionalISecurityGroup[]SecurityGroupsoptional*[]ISecurityGroup#
Which security group to associate with the script's project network interfaces.

Default: Security group will be automatically created.

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

Only used if 'vpc' is supplied.

subnetSelectionoptionalSubnetSelectionsubnet_selectionoptionalSubnetSelectionsubnetSelectionoptionalSubnetSelectionSubnetSelectionoptionalSubnetSelectionSubnetSelectionoptionalSubnetSelection#
Which subnets to use.

Default: All private subnets.

Only used if 'vpc' is supplied.

timeoutoptionalDurationtimeoutoptionalDurationtimeoutoptionalDurationTimeoutoptionalDurationTimeoutoptionalDuration= Duration.hours(1)#
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.

vpcoptionalIVpcvpcoptionalIVpcvpcoptionalIVpcVpcoptionalIVpcVpcoptionalIVpc#
The VPC where to execute the SimpleSynth.

Default: No VPC