Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pipelines): add support for caching to codebuild steps #19084

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/@aws-cdk/pipelines/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,9 @@ new pipelines.CodeBuildStep('Synth', {
subnetSelection: { subnetType: ec2.SubnetType.PRIVATE },
securityGroups: [mySecurityGroup],

// Control caching
cache: codebuild.Cache.bucket(new s3.Bucket(this, 'Cache')),

// Additional policy statements for the execution role
rolePolicyStatements: [
new iam.PolicyStatement({ /* ... */ }),
Expand Down
15 changes: 15 additions & 0 deletions packages/@aws-cdk/pipelines/lib/codepipeline/codebuild-step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ export interface CodeBuildStepProps extends ShellStepProps {
*/
readonly subnetSelection?: ec2.SubnetSelection;

/**
* Caching strategy to use.
*
* @default - No cache
*/
readonly cache?: codebuild.Cache;

/**
* Policy statements to add to role used during the synth
*
Expand Down Expand Up @@ -132,6 +139,13 @@ export class CodeBuildStep extends ShellStep {
*/
public readonly subnetSelection?: ec2.SubnetSelection;

/**
* Caching strategy to use.
*
* @default - No cache
*/
public readonly cache?: codebuild.Cache;

/**
* Policy statements to add to role used during the synth
*
Expand Down Expand Up @@ -182,6 +196,7 @@ export class CodeBuildStep extends ShellStep {
this._partialBuildSpec = props.partialBuildSpec;
this.vpc = props.vpc;
this.subnetSelection = props.subnetSelection;
this.cache = props.cache;
this.role = props.role;
this.rolePolicyStatements = props.rolePolicyStatements;
this.securityGroups = props.securityGroups;
Expand Down
7 changes: 7 additions & 0 deletions packages/@aws-cdk/pipelines/lib/codepipeline/codepipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,13 @@ export interface CodeBuildOptions {
*/
readonly subnetSelection?: ec2.SubnetSelection;

/**
* Caching strategy to use.
*
* @default - No cache
*/
readonly cache?: cb.Cache;

/**
* 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export class CodeBuildFactory implements ICodePipelineActionFactory {
partialBuildSpec: step.partialBuildSpec,
vpc: step.vpc,
subnetSelection: step.subnetSelection,
cache: step.cache,
timeout: step.timeout,
}),
});
Expand Down Expand Up @@ -290,6 +291,7 @@ export class CodeBuildFactory implements ICodePipelineActionFactory {
vpc: projectOptions.vpc,
subnetSelection: projectOptions.subnetSelection,
securityGroups: projectOptions.securityGroups,
cache: projectOptions.cache,
buildSpec: projectBuildSpec,
role: this.props.role,
timeout: projectOptions.timeout,
Expand Down Expand Up @@ -409,6 +411,7 @@ export function mergeCodeBuildOptions(...opts: Array<CodeBuildOptions | undefine
vpc: b.vpc ?? a.vpc,
subnetSelection: b.subnetSelection ?? a.subnetSelection,
timeout: b.timeout ?? a.timeout,
cache: b.cache ?? a.cache,
};
}
}
Expand Down