Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(codepipeline): final form of the CodeBuild Pipeline action #2716

Merged
merged 1 commit into from
Jun 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -89,7 +89,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 @@ -348,7 +348,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 @@ -166,7 +166,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 @@ -233,11 +233,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 @@ -246,7 +246,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),
resource: props.project,
configuration: {
ProjectName: props.project.projectName,
Expand Down Expand Up @@ -107,12 +108,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 @@ -70,7 +70,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 @@ -103,7 +103,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
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ export = {
actionName: 'CodeBuild',
project,
input: sourceOutput,
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