# CodeBuildStepProps

Construction props for a CodeBuildStep.

Extends: CodeBuildStepProps
Extends: ShellStepProps
Used as props by: CodeBuildStep

- Source: [`pipelines/lib/codepipeline/codebuild-step.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/pipelines/lib/codepipeline/codebuild-step.ts#L15)
- Type last changed: v2.77.0 · 26 Apr 2023

## 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

- `actionRole`: [IRole](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — Custom execution role to be used for the Code Build Action.

  **Default:** A role is automatically created

- `additionalInputs`: { [key: string]: [IFileSetProducer](/cdk/api/v2/docs/aws-cdk-lib.pipelines.IFileSetProducer.html) } — Additional FileSets to put in other directories.

  **Default:** No additional inputs

  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'),
    }
  });
  ```

- `buildEnvironment`: [BuildEnvironment](/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.BuildEnvironment.html) — Changes to environment.

  **Default:** Use the pipeline's default build environment

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

- `cache`: [Cache](/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.Cache.html) — Caching strategy to use.

  **Default:** No cache

- `commands`: string[] (required) — Commands to run.

- `env`: { [key: string]: string } — Environment variables to set.

  **Default:** No environment variables

- `envFromCfnOutputs`: { [key: string]: [CfnOutput](/cdk/api/v2/docs/aws-cdk-lib.CfnOutput.html) } — Set environment variables based on Stack Outputs.

  **Default:** No environment variables created from 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.

- `fileSystemLocations`: [IFileSystemLocation](/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.IFileSystemLocation.html)[] — 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.

- `input`: [IFileSetProducer](/cdk/api/v2/docs/aws-cdk-lib.pipelines.IFileSetProducer.html) — 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.

- `installCommands`: 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`.

- `logging`: [LoggingOptions](/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.LoggingOptions.html) — 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.

- `partialBuildSpec`: [BuildSpec](/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.BuildSpec.html) — Additional configuration that can only be configured via BuildSpec.

  **Default:** BuildSpec completely derived from other properties

  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.

- `primaryOutputDirectory`: 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.

- `projectName`: string — Name for the generated CodeBuild project.

  **Default:** Automatically generated

- `role`: [IRole](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — Custom execution role to be used for the CodeBuild project.

  **Default:** A role is automatically created

- `rolePolicyStatements`: [PolicyStatement](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.PolicyStatement.html)[] — 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.

- `securityGroups`: [ISecurityGroup](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.ISecurityGroup.html)[] — 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.

- `subnetSelection`: [SubnetSelection](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.SubnetSelection.html) — Which subnets to use.

  **Default:** All private subnets.

  Only used if 'vpc' is supplied.

- `timeout`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = 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.

- `vpc`: [IVpc](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html) — The VPC where to execute the SimpleSynth.

  **Default:** No VPC
