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 Sep 17, 2018
1 parent 965b918 commit cb20617
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
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, name, {
pipeline: this,
});
}

/**
* Adds a statement to the pipeline role.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const repo = new codecommit.Repository(stack, 'MyRepo', { repositoryName: 'my-re

const pipeline = new codepipeline.Pipeline(stack, 'Pipeline');

const sourceStage = new codepipeline.Stage(pipeline, 'source', { pipeline });
const sourceStage = pipeline.addStage('source');
repo.addToPipeline(sourceStage, 'source', {
artifactName: 'SourceArtifact',
});
Expand Down

0 comments on commit cb20617

Please sign in to comment.