Skip to content

Commit

Permalink
feat(codepipeline-actions): support combining batch build artifacts i…
Browse files Browse the repository at this point in the history
…n CodeBuildAction (#15457)

See this [doc](https://docs.aws.amazon.com/codebuild/latest/userguide/sample-pipeline-batch.html) which says

> To enable batch builds in CodePipeline, set the BatchEnabled parameter of the configuration object to true. To combine the build artifacts into the same location, set the CombineArtifacts parameter of the configuration object to true.

The configuration object it is referring to is [this](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-codepipeline-pipeline-stages-actions.html#cfn-codepipeline-pipeline-stages-actions-configuration).

Closes #15455
  • Loading branch information
martinmicunda authored Jul 9, 2021
1 parent 23abe22 commit 0952f1f
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-codepipeline-actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ const buildAction = new codepipeline_actions.CodeBuildAction({
project,
input: sourceOutput,
outputs: [new codepipeline.Artifact()], // optional
executeBatchBuild: true // optional, defaults to false
executeBatchBuild: true, // optional, defaults to false
combineBatchBuildArtifacts: true, // optional, defaults to false
});

new codepipeline.Pipeline(this, 'MyPipeline', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ export interface CodeBuildActionProps extends codepipeline.CommonAwsActionProps
* @default false
*/
readonly executeBatchBuild?: boolean;

/**
* Combine the build artifacts for a batch builds.
*
* Enabling this will combine the build artifacts into the same location for batch builds.
* If `executeBatchBuild` is not set to `true`, this property is ignored.
*
* @default false
*/
readonly combineBatchBuildArtifacts?: boolean;
}

/**
Expand Down Expand Up @@ -216,6 +226,10 @@ export class CodeBuildAction extends Action {
if (this.props.executeBatchBuild) {
configuration.BatchEnabled = 'true';
this.props.project.enableBatchBuilds();

if (this.props.combineBatchBuildArtifacts) {
configuration.CombineArtifacts = 'true';
}
}
return {
configuration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,63 @@ nodeunitShim({
test.done();
},

'sets the CombineArtifacts configuration'(test: Test) {
const stack = new Stack();

const codeBuildProject = new codebuild.PipelineProject(stack, 'CodeBuild');

const sourceOutput = new codepipeline.Artifact();
new codepipeline.Pipeline(stack, 'Pipeline', {
stages: [
{
stageName: 'Source',
actions: [
new cpactions.S3SourceAction({
actionName: 'S3_Source',
bucket: new s3.Bucket(stack, 'Bucket'),
bucketKey: 'key',
output: sourceOutput,
}),
],
},
{
stageName: 'Build',
actions: [
new cpactions.CodeBuildAction({
actionName: 'CodeBuild',
input: sourceOutput,
project: codeBuildProject,
executeBatchBuild: true,
combineBatchBuildArtifacts: true,
}),
],
},
],
});

expect(stack).to(haveResourceLike('AWS::CodePipeline::Pipeline', {
'Stages': [
{
'Name': 'Source',
},
{
'Name': 'Build',
'Actions': [
{
'Name': 'CodeBuild',
'Configuration': {
'BatchEnabled': 'true',
'CombineArtifacts': 'true',
},
},
],
},
],
}));

test.done();
},

'environment variables': {
'should fail by default when added to a Pipeline while using a secret value in a plaintext variable'(test: Test) {
const stack = new Stack();
Expand Down

0 comments on commit 0952f1f

Please sign in to comment.