Skip to content

Commit cbed348

Browse files
authored
fix(codebuild): allow FILE_PATH webhook filter for BitBucket (#13186)
Remove restrictions around FILE_PATH for Bitbucket sources as this is supported by CloudFormation now. Closes #13175 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent ae0185d commit cbed348

File tree

2 files changed

+10
-23
lines changed

2 files changed

+10
-23
lines changed

packages/@aws-cdk/aws-codebuild/lib/source.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ export class FilterGroup {
381381
* Create a new FilterGroup with an added condition:
382382
* the push that is the source of the event must affect a file that matches the given pattern.
383383
* Note that you can only use this method if this Group contains only the `PUSH` event action,
384-
* and only for GitHub and GitHubEnterprise sources.
384+
* and only for GitHub, Bitbucket and GitHubEnterprise sources.
385385
*
386386
* @param pattern a regular expression
387387
*/
@@ -393,7 +393,7 @@ export class FilterGroup {
393393
* Create a new FilterGroup with an added condition:
394394
* the push that is the source of the event must not affect a file that matches the given pattern.
395395
* Note that you can only use this method if this Group contains only the `PUSH` event action,
396-
* and only for GitHub and GitHubEnterprise sources.
396+
* and only for GitHub, Bitbucket and GitHubEnterprise sources.
397397
*
398398
* @param pattern a regular expression
399399
*/
@@ -788,11 +788,6 @@ class BitBucketSource extends ThirdPartyGitSource {
788788
throw new Error('BitBucket sources do not support the PULL_REQUEST_REOPENED webhook event action');
789789
}
790790

791-
// they also don't support file path conditions
792-
if (this.anyWebhookFilterContainsFilePathConditions()) {
793-
throw new Error('BitBucket sources do not support file path conditions for webhook filters');
794-
}
795-
796791
const superConfig = super.bind(_scope, _project);
797792
return {
798793
sourceProperty: {
@@ -809,12 +804,6 @@ class BitBucketSource extends ThirdPartyGitSource {
809804
return fg._actions.findIndex(a => a === EventAction.PULL_REQUEST_REOPENED) !== -1;
810805
}) !== -1;
811806
}
812-
813-
private anyWebhookFilterContainsFilePathConditions() {
814-
return this.webhookFilters.findIndex(fg => {
815-
return fg._filters.findIndex(f => f.type === WebhookFilterTypes.FILE_PATH) !== -1;
816-
}) !== -1;
817-
}
818807
}
819808

820809
function set2Array<T>(set: Set<T>): T[] {

packages/@aws-cdk/aws-codebuild/test/test.codebuild.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,19 +1801,17 @@ export = {
18011801
test.done();
18021802
},
18031803

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

1808-
test.throws(() => {
1809-
new codebuild.Project(stack, 'Project', {
1810-
source: codebuild.Source.bitBucket({
1811-
owner: 'owner',
1812-
repo: 'repo',
1813-
webhookFilters: [filterGroup],
1814-
}),
1815-
});
1816-
}, /BitBucket sources do not support file path conditions for webhook filters/);
1808+
new codebuild.Project(stack, 'Project', {
1809+
source: codebuild.Source.bitBucket({
1810+
owner: 'owner',
1811+
repo: 'repo',
1812+
webhookFilters: [filterGroup],
1813+
}),
1814+
});
18171815

18181816
test.done();
18191817
},

0 commit comments

Comments
 (0)