Skip to content

Commit

Permalink
feat(codebuild): add webhook Filter Groups. (#2319)
Browse files Browse the repository at this point in the history
Fixes #1842
  • Loading branch information
Kaixiang-AWS authored and skinny85 committed May 2, 2019
1 parent 4740446 commit fd74d07
Show file tree
Hide file tree
Showing 4 changed files with 527 additions and 47 deletions.
7 changes: 5 additions & 2 deletions packages/@aws-cdk/aws-codebuild/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ Example:
const gitHubSource = new codebuild.GitHubSource({
owner: 'awslabs',
repo: 'aws-cdk',
webhook: true, // optional, default: false
webhook: true, // optional, default: true if `webhookFilteres` were provided, false otherwise
webhookFilters: [
codebuild.FilterGroup.inEventOf(codebuild.EventAction.PUSH).andBranchIs('master'),
], // optional, by default all pushes and Pull Requests will trigger a build
});
```

Expand Down Expand Up @@ -283,4 +286,4 @@ new Project(stack, 'MyProject', {
securityGroups: [securityGroup],
vpc: vpc
});
```
```
10 changes: 5 additions & 5 deletions packages/@aws-cdk/aws-codebuild/lib/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ export class Project extends ProjectBase {
throw new Error(`Badge is not supported for source type ${this.source.type}`);
}

const sourceJson = this.source.toSourceJSON();
const sourceJson = this.source._toSourceJSON();
if (typeof buildSpec === 'string') {
return {
...sourceJson,
Expand Down Expand Up @@ -670,7 +670,7 @@ export class Project extends ProjectBase {
timeoutInMinutes: props.timeout,
secondarySources: new Token(() => this.renderSecondarySources()),
secondaryArtifacts: new Token(() => this.renderSecondaryArtifacts()),
triggers: this.source.buildTriggers(),
triggers: this.source._buildTriggers(),
vpcConfig: this.configureVpc(props),
});

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

private renderSecondaryArtifacts(): CfnProject.ArtifactsProperty[] | undefined {
Expand Down Expand Up @@ -889,15 +889,15 @@ export class Project extends ProjectBase {
if (props.artifacts) {
return props.artifacts;
}
if (this.source.toSourceJSON().type === CODEPIPELINE_TYPE) {
if (this.source._toSourceJSON().type === CODEPIPELINE_TYPE) {
return new CodePipelineBuildArtifacts();
} else {
return new NoBuildArtifacts();
}
}

private validateCodePipelineSettings(artifacts: BuildArtifacts) {
const sourceType = this.source.toSourceJSON().type;
const sourceType = this.source._toSourceJSON().type;
const artifactsType = artifacts.toArtifactsJSON().type;

if ((sourceType === CODEPIPELINE_TYPE || artifactsType === CODEPIPELINE_TYPE) &&
Expand Down
Loading

0 comments on commit fd74d07

Please sign in to comment.