Skip to content

Commit

Permalink
feat(codepipeline-actions): Add detectChanges option to BitBucketSour…
Browse files Browse the repository at this point in the history
…ceAction (#13656)

Adds optional `DetectChanges` to BitBucketSourceAction

https://docs.aws.amazon.com/codepipeline/latest/userguide/action-reference-CodestarConnectionSource.html

This option is available in the AWS console when configuring the Source stage.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
bryan-hunter authored Mar 22, 2021
1 parent 4fde59a commit f2436bf
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ export interface BitBucketSourceActionProps extends codepipeline.CommonAwsAction
* @see https://docs.aws.amazon.com/codepipeline/latest/userguide/action-reference-CodestarConnectionSource.html#action-reference-CodestarConnectionSource-config
*/
readonly codeBuildCloneOutput?: boolean;

/**
* Controls automatically starting your pipeline when a new commit
* is made on the configured repository and branch. If unspecified,
* the default value is true, and the field does not display by default.
*
* @default true
* @see https://docs.aws.amazon.com/codepipeline/latest/userguide/action-reference-CodestarConnectionSource.html
*/
readonly triggerOnPush?: boolean;
}

/**
Expand Down Expand Up @@ -124,6 +134,7 @@ export class BitBucketSourceAction extends Action {
OutputArtifactFormat: this.props.codeBuildCloneOutput === true
? 'CODEBUILD_CLONE_REF'
: undefined,
DetectChanges: this.props.triggerOnPush,
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,50 @@ nodeunitShim({

test.done();
},

'setting triggerOnPush=false reflects in the configuration'(test: Test) {
const stack = new Stack();

createBitBucketAndCodeBuildPipeline(stack, {
triggerOnPush: false,
});

expect(stack).to(haveResourceLike('AWS::CodePipeline::Pipeline', {
'Stages': [
{
'Name': 'Source',
'Actions': [
{
'Name': 'BitBucket',
'ActionTypeId': {
'Owner': 'AWS',
'Provider': 'CodeStarSourceConnection',
},
'Configuration': {
'ConnectionArn': 'arn:aws:codestar-connections:us-east-1:123456789012:connection/12345678-abcd-12ab-34cdef5678gh',
'FullRepositoryId': 'aws/aws-cdk',
'BranchName': 'master',
'DetectChanges': false,
},
},
],
},
{
'Name': 'Build',
'Actions': [
{
'Name': 'CodeBuild',
},
],
},
],
}));

test.done();
},
});

function createBitBucketAndCodeBuildPipeline(stack: Stack, props: { codeBuildCloneOutput: boolean }): void {
function createBitBucketAndCodeBuildPipeline(stack: Stack, props: Partial<cpactions.BitBucketSourceActionProps>): void {
const sourceOutput = new codepipeline.Artifact();
new codepipeline.Pipeline(stack, 'Pipeline', {
stages: [
Expand All @@ -97,7 +138,7 @@ function createBitBucketAndCodeBuildPipeline(stack: Stack, props: { codeBuildClo
repo: 'aws-cdk',
output: sourceOutput,
connectionArn: 'arn:aws:codestar-connections:us-east-1:123456789012:connection/12345678-abcd-12ab-34cdef5678gh',
codeBuildCloneOutput: props.codeBuildCloneOutput,
...props,
}),
],
},
Expand Down

0 comments on commit f2436bf

Please sign in to comment.