Skip to content

Commit fd74d07

Browse files
Kaixiang-AWSskinny85
authored andcommitted
feat(codebuild): add webhook Filter Groups. (#2319)
Fixes #1842
1 parent 4740446 commit fd74d07

File tree

4 files changed

+527
-47
lines changed

4 files changed

+527
-47
lines changed

packages/@aws-cdk/aws-codebuild/README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ Example:
9090
const gitHubSource = new codebuild.GitHubSource({
9191
owner: 'awslabs',
9292
repo: 'aws-cdk',
93-
webhook: true, // optional, default: false
93+
webhook: true, // optional, default: true if `webhookFilteres` were provided, false otherwise
94+
webhookFilters: [
95+
codebuild.FilterGroup.inEventOf(codebuild.EventAction.PUSH).andBranchIs('master'),
96+
], // optional, by default all pushes and Pull Requests will trigger a build
9497
});
9598
```
9699

@@ -283,4 +286,4 @@ new Project(stack, 'MyProject', {
283286
securityGroups: [securityGroup],
284287
vpc: vpc
285288
});
286-
```
289+
```

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ export class Project extends ProjectBase {
625625
throw new Error(`Badge is not supported for source type ${this.source.type}`);
626626
}
627627

628-
const sourceJson = this.source.toSourceJSON();
628+
const sourceJson = this.source._toSourceJSON();
629629
if (typeof buildSpec === 'string') {
630630
return {
631631
...sourceJson,
@@ -670,7 +670,7 @@ export class Project extends ProjectBase {
670670
timeoutInMinutes: props.timeout,
671671
secondarySources: new Token(() => this.renderSecondarySources()),
672672
secondaryArtifacts: new Token(() => this.renderSecondaryArtifacts()),
673-
triggers: this.source.buildTriggers(),
673+
triggers: this.source._buildTriggers(),
674674
vpcConfig: this.configureVpc(props),
675675
});
676676

@@ -822,7 +822,7 @@ export class Project extends ProjectBase {
822822
private renderSecondarySources(): CfnProject.SourceProperty[] | undefined {
823823
return this._secondarySources.length === 0
824824
? undefined
825-
: this._secondarySources.map((secondarySource) => secondarySource.toSourceJSON());
825+
: this._secondarySources.map((secondarySource) => secondarySource._toSourceJSON());
826826
}
827827

828828
private renderSecondaryArtifacts(): CfnProject.ArtifactsProperty[] | undefined {
@@ -889,15 +889,15 @@ export class Project extends ProjectBase {
889889
if (props.artifacts) {
890890
return props.artifacts;
891891
}
892-
if (this.source.toSourceJSON().type === CODEPIPELINE_TYPE) {
892+
if (this.source._toSourceJSON().type === CODEPIPELINE_TYPE) {
893893
return new CodePipelineBuildArtifacts();
894894
} else {
895895
return new NoBuildArtifacts();
896896
}
897897
}
898898

899899
private validateCodePipelineSettings(artifacts: BuildArtifacts) {
900-
const sourceType = this.source.toSourceJSON().type;
900+
const sourceType = this.source._toSourceJSON().type;
901901
const artifactsType = artifacts.toArtifactsJSON().type;
902902

903903
if ((sourceType === CODEPIPELINE_TYPE || artifactsType === CODEPIPELINE_TYPE) &&

0 commit comments

Comments
 (0)