Skip to content

Commit

Permalink
feat(codepipeline): final form of the CodeBuild Pipeline action.
Browse files Browse the repository at this point in the history
BREAKING CHANGE: the output and extraOutputs properties of the CodeBuildAction were merged into one property outputs.
  • Loading branch information
skinny85 committed Jun 1, 2019
1 parent cb2b334 commit 658b1d0
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 36 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/app-delivery/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const buildAction = new codepipeline_actions.CodeBuildAction({
actionName: 'CodeBuild',
project,
input: sourceOutput,
output: synthesizedApp,
outputs: [synthesizedApp],
});
pipeline.addStage({
name: 'build',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ function createSelfUpdatingStack(pipelineStack: cdk.Stack): SelfUpdatingPipeline
actionName: 'CodeBuild',
project,
input: sourceOutput,
output: buildOutput,
outputs: [buildOutput],
});
pipeline.addStage({
name: 'build',
Expand Down
8 changes: 4 additions & 4 deletions packages/@aws-cdk/aws-codepipeline-actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const buildAction = new codepipeline_actions.CodeBuildAction({
actionName: 'CodeBuild',
project,
input: sourceOutput,
output: new codepipeline.Artifact(), // optional
outputs: [new codepipeline.Artifact()], // optional
});

new codepipeline.Pipeline(this, 'MyPipeline', {
Expand Down Expand Up @@ -221,11 +221,11 @@ const buildAction = new codepipeline_actions.CodeBuildAction({
actionName: 'Build',
project,
input: sourceOutput1,
output: new codepipeline.Artifact('artifact1'), // for better buildspec readability - see below
extraInputs: [
sourceOutput2, // this is where 'source2' comes from
],
extraOutputs: [
outputs: [
new codepipeline.Artifact('artifact1'), // for better buildspec readability - see below
new codepipeline.Artifact('artifact2'),
],
});
Expand All @@ -234,7 +234,7 @@ const buildAction = new codepipeline_actions.CodeBuildAction({
**Note**: when a CodeBuild Action in a Pipeline has more than one output, it
only uses the `secondary-artifacts` field of the buildspec, never the
primary output specification directly under `artifacts`. Because of that, it
pays to name even your primary output artifact on the Pipeline, like we did
pays to explicitly name all output artifacts of that Action, like we did
above, so that you know what name to use in the buildspec.
Example buildspec for the above project:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ export interface CodeBuildActionProps extends codepipeline.CommonActionProps {
readonly extraInputs?: codepipeline.Artifact[];

/**
* The optional primary output Artifact of this action.
*/
readonly output?: codepipeline.Artifact;

/**
* The list of additional output Artifacts for this action.
* The list of output Artifacts for this action.
* **Note**: if you specify more than one output Artifact here,
* you cannot use the primary 'artifacts' section of the buildspec;
* you have to use the 'secondary-artifacts' section instead.
* See https://docs.aws.amazon.com/codebuild/latest/userguide/sample-multi-in-out.html
* for details.
*
* @default the action will not have any outputs
*/
readonly extraOutputs?: codepipeline.Artifact[];
readonly outputs?: codepipeline.Artifact[];

/**
* The action's Project.
Expand Down Expand Up @@ -74,7 +76,6 @@ export class CodeBuildAction extends codepipeline.Action {
provider: 'CodeBuild',
artifactBounds: { minInputs: 1, maxInputs: 5, minOutputs: 0, maxOutputs: 5 },
inputs: [props.input, ...props.extraInputs || []],
outputs: getOutputs(props),
configuration: {
ProjectName: props.project.projectName,
},
Expand Down Expand Up @@ -105,12 +106,3 @@ export class CodeBuildAction extends codepipeline.Action {
}
}
}

function getOutputs(props: CodeBuildActionProps): codepipeline.Artifact[] {
const ret = new Array<codepipeline.Artifact>();
if (props.output) {
ret.push(props.output);
}
ret.push(...props.extraOutputs || []);
return ret;
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export = {
actionName: 'build',
project,
input: sourceOutput,
output: buildOutput,
outputs: [buildOutput],
});
pipeline.addStage({
name: 'build',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const cdkBuildAction = new codepipeline_actions.CodeBuildAction({
actionName: 'CDK_Build',
project: cdkBuildProject,
input: cdkSourceOutput,
output: cdkBuildOutput,
outputs: [cdkBuildOutput],
});

// build your Lambda code, using CodeBuild
Expand Down Expand Up @@ -106,7 +106,7 @@ const lambdaBuildAction = new codepipeline_actions.CodeBuildAction({
actionName: 'Lambda_Build',
project: lambdaBuildProject,
input: lambdaSourceOutput,
output: lambdaBuildOutput,
outputs: [lambdaBuildOutput],
});

pipeline.addStage({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ const buildAction = new cpactions.CodeBuildAction({
extraInputs: [
source2Output,
],
output: new codepipeline.Artifact(),
extraOutputs: [
outputs: [
new codepipeline.Artifact(),
new codepipeline.Artifact(),
],
});
Expand All @@ -63,7 +63,7 @@ const testAction = new cpactions.CodeBuildAction({
extraInputs: [
source1Output,
],
extraOutputs: [
outputs: [
new codepipeline.Artifact('CustomOutput2'),
],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const buildAction = new cpactions.CodeBuildAction({
actionName: 'build',
project,
input: sourceOutput,
output: new codepipeline.Artifact(),
outputs: [new codepipeline.Artifact()],
});
const testAction = new cpactions.CodeBuildAction({
type: cpactions.CodeBuildActionType.TEST,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const buildAction = new cpactions.CodeBuildAction({
actionName: 'CodeBuild',
project,
input: sourceOutput,
output: buildOutput,
outputs: [buildOutput],
});

new codepipeline.Pipeline(stack, 'MyPipeline', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pipeline.addStage({
actionName: 'CodeBuildAction',
input: sourceOutput,
project,
output: new codepipeline.Artifact(),
outputs: [new codepipeline.Artifact()],
}),
],
});
Expand Down
10 changes: 6 additions & 4 deletions packages/decdk/examples/pipeline.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@
"name": "Source"
}
},
"output": {
"artifact": {
"name": "Build"
"outputs": [
{
"artifact": {
"name": "Build"
}
}
}
]
}
}
]
Expand Down

0 comments on commit 658b1d0

Please sign in to comment.