Skip to content

Commit

Permalink
fix(codebuild): Allow Bitbucket FILE_PATH filter
Browse files Browse the repository at this point in the history
Remove restrictions around FILE_PATH for Bitbucket sources as this is
supported by CloudFormation now.

closes #13175
  • Loading branch information
Tom Lei committed Feb 22, 2021
1 parent 8f1cfe4 commit 0805385
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 21 deletions.
11 changes: 0 additions & 11 deletions packages/@aws-cdk/aws-codebuild/lib/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -788,11 +788,6 @@ class BitBucketSource extends ThirdPartyGitSource {
throw new Error('BitBucket sources do not support the PULL_REQUEST_REOPENED webhook event action');
}

// they also don't support file path conditions
if (this.anyWebhookFilterContainsFilePathConditions()) {
throw new Error('BitBucket sources do not support file path conditions for webhook filters');
}

const superConfig = super.bind(_scope, _project);
return {
sourceProperty: {
Expand All @@ -809,12 +804,6 @@ class BitBucketSource extends ThirdPartyGitSource {
return fg._actions.findIndex(a => a === EventAction.PULL_REQUEST_REOPENED) !== -1;
}) !== -1;
}

private anyWebhookFilterContainsFilePathConditions() {
return this.webhookFilters.findIndex(fg => {
return fg._filters.findIndex(f => f.type === WebhookFilterTypes.FILE_PATH) !== -1;
}) !== -1;
}
}

function set2Array<T>(set: Set<T>): T[] {
Expand Down
18 changes: 8 additions & 10 deletions packages/@aws-cdk/aws-codebuild/test/test.codebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1801,19 +1801,17 @@ export = {
test.done();
},

'BitBucket sources do not support file path conditions'(test: Test) {
'BitBucket sources support file path conditions'(test: Test) {
const stack = new cdk.Stack();
const filterGroup = codebuild.FilterGroup.inEventOf(codebuild.EventAction.PUSH).andFilePathIs('.*');

test.throws(() => {
new codebuild.Project(stack, 'Project', {
source: codebuild.Source.bitBucket({
owner: 'owner',
repo: 'repo',
webhookFilters: [filterGroup],
}),
});
}, /BitBucket sources do not support file path conditions for webhook filters/);
new codebuild.Project(stack, 'Project', {
source: codebuild.Source.bitBucket({
owner: 'owner',
repo: 'repo',
webhookFilters: [filterGroup],
}),
});

test.done();
},
Expand Down

0 comments on commit 0805385

Please sign in to comment.