Skip to content

Commit

Permalink
fix(codebuild): revert validation that only a project with source COD…
Browse files Browse the repository at this point in the history
…EPIPELINE can be added to a pipeline (aws#4689)

Fixes aws#4646
  • Loading branch information
skinny85 authored and mergify[bot] committed Oct 26, 2019
1 parent ed639ca commit 8e72720
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
4 changes: 0 additions & 4 deletions packages/@aws-cdk/aws-codebuild/lib/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -779,10 +779,6 @@ export class Project extends ProjectBase {
* @param options additional options for the binding
*/
public bindToCodePipeline(_scope: Construct, options: BindToCodePipelineOptions): void {
if (this.source.type !== CODEPIPELINE_SOURCE_ARTIFACTS_TYPE) {
throw new Error('Only a PipelineProject can be added to a CodePipeline');
}

// work around a bug in CodeBuild: it ignores the KMS key set on the pipeline,
// and always uses its own, project-level key
if (options.artifactBucket.encryptionKey && !this._encryptionKey) {
Expand Down
10 changes: 4 additions & 6 deletions packages/@aws-cdk/aws-codebuild/test/test.project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export = {
test.done();
},

'cannot have bindToCodePipeline() be called on it'(test: Test) {
'can be added to a CodePipeline'(test: Test) {
const stack = new cdk.Stack();
const project = new codebuild.Project(stack, 'Project', {
source: codebuild.Source.gitHub({
Expand All @@ -159,11 +159,9 @@ export = {
}),
});

test.throws(() => {
project.bindToCodePipeline(project, {
artifactBucket: new s3.Bucket(stack, 'Bucket'),
});
}, /Only a PipelineProject can be added to a CodePipeline/);
project.bindToCodePipeline(project, {
artifactBucket: new s3.Bucket(stack, 'Bucket'),
}); // no exception

test.done();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1453,7 +1453,7 @@
"Type": "AWS::CodeBuild::Project",
"Properties": {
"Artifacts": {
"Type": "CODEPIPELINE"
"Type": "NO_ARTIFACTS"
},
"EncryptionKey": {
"Fn::GetAtt": [
Expand All @@ -1475,7 +1475,7 @@
},
"Source": {
"BuildSpec": "{\n \"version\": \"0.2\",\n \"phases\": {\n \"install\": {\n \"commands\": \"npm install\"\n },\n \"build\": {\n \"commands\": [\n \"npm run build\",\n \"npm run cdk synth LambdaStack -- -o .\"\n ]\n }\n },\n \"artifacts\": {\n \"files\": \"LambdaStack.template.yaml\"\n }\n}",
"Type": "CODEPIPELINE"
"Type": "NO_SOURCE"
}
}
},
Expand Down Expand Up @@ -1637,7 +1637,7 @@
"Type": "AWS::CodeBuild::Project",
"Properties": {
"Artifacts": {
"Type": "CODEPIPELINE"
"Type": "NO_ARTIFACTS"
},
"EncryptionKey": {
"Fn::GetAtt": [
Expand All @@ -1659,7 +1659,7 @@
},
"Source": {
"BuildSpec": "{\n \"version\": \"0.2\",\n \"phases\": {\n \"install\": {\n \"commands\": \"npm install\"\n },\n \"build\": {\n \"commands\": \"npm run build\"\n }\n },\n \"artifacts\": {\n \"files\": [\n \"index.js\",\n \"node_modules/**/*\"\n ]\n }\n}",
"Type": "CODEPIPELINE"
"Type": "NO_SOURCE"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pipeline.addStage({
// synthesize the Lambda CDK template, using CodeBuild
// the below values are just examples, assuming your CDK code is in TypeScript/JavaScript -
// adjust the build environment and/or commands accordingly
const cdkBuildProject = new codebuild.PipelineProject(pipelineStack, 'CdkBuildProject', {
const cdkBuildProject = new codebuild.Project(pipelineStack, 'CdkBuildProject', {
environment: {
buildImage: codebuild.LinuxBuildImage.UBUNTU_14_04_NODEJS_10_1_0,
},
Expand Down Expand Up @@ -80,7 +80,7 @@ const cdkBuildAction = new codepipeline_actions.CodeBuildAction({
// build your Lambda code, using CodeBuild
// again, this example assumes your Lambda is written in TypeScript/JavaScript -
// make sure to adjust the build environment and/or commands if they don't match your specific situation
const lambdaBuildProject = new codebuild.PipelineProject(pipelineStack, 'LambdaBuildProject', {
const lambdaBuildProject = new codebuild.Project(pipelineStack, 'LambdaBuildProject', {
environment: {
buildImage: codebuild.LinuxBuildImage.UBUNTU_14_04_NODEJS_10_1_0,
},
Expand Down

0 comments on commit 8e72720

Please sign in to comment.