Skip to content

Commit

Permalink
feat(aws-codepipeline): New Pipeline#addStage convenience method.
Browse files Browse the repository at this point in the history
Added to make creating Stage objects a little more concise.
  • Loading branch information
skinny85 committed Aug 30, 2018
1 parent e1785d4 commit c1e3ee1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
7 changes: 7 additions & 0 deletions packages/@aws-cdk/aws-codepipeline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ const sourceStage = new Stage(this, 'Source', {
});
```

There's also a utility method on the `Pipeline` class that can be used for this purpose:

```ts
// equivalent to the code above:
const sourceStage = pipeline.addStage('Source');
```

Add an Action to a Stage:

```ts
Expand Down
13 changes: 13 additions & 0 deletions packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,19 @@ export class Pipeline extends cdk.Construct implements events.IEventRuleTarget {
}));
}

/**
* Convenience method for creating a new {@link Stage},
* and adding it to this Pipeline.
*
* @param name the name of the newly created Stage
* @returns the newly created Stage
*/
public addStage(name: string): Stage {
return new Stage(this.parent!, name, {
pipeline: this,
});
}

/**
* Adds a statement to the pipeline role.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ const pipeline = new codepipeline.Pipeline(stack, 'Pipeline', {
artifactBucket: bucket,
});

const sourceStage = new codepipeline.Stage(stack, 'Source', { pipeline });
const sourceStage = pipeline.addStage('Source');
const sourceAction = bucket.addToPipeline(sourceStage, 'S3Source', {
bucketKey: 'application.zip',
artifactName: 'SourceOutput',
});

const deployStage = new codepipeline.Stage(stack, 'Deploy', { pipeline });
const deployStage = pipeline.addStage('Deploy');
new codedeploy.PipelineDeployAction(stack, 'CodeDeploy', {
stage: deployStage,
inputArtifact: sourceAction.artifact,
Expand Down

0 comments on commit c1e3ee1

Please sign in to comment.