Skip to content

Commit

Permalink
Add support for caching
Browse files Browse the repository at this point in the history
  • Loading branch information
johnameyer committed Mar 5, 2022
1 parent e0f863a commit a610712
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
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

0 comments on commit a610712

Please sign in to comment.