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

docs(pipelines): add examples for pipeline variables #19288

Merged
merged 6 commits into from
Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
17 changes: 17 additions & 0 deletions packages/@aws-cdk/pipelines/lib/codepipeline/codebuild-step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,24 @@ export class CodeBuildStep extends ShellStep {
* The variable must be set in the shell of the CodeBuild step when
* it finishes its `post_build` phase.
*
* ```ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should not be here?

* ```
*
* @param variableName the name of the variable for reference.
* @example
* // Access the output of one CodeBuildStep in another CodeBuildStep
* declare const pipeline: pipelines.CodePipeline;
*
* const step1 = new pipelines.CodeBuildStep('Step1', {
* commands: ['export MY_VAR=hello'],
* });
*
* const step2 = new pipelines.CodeBuildStep('Step2', {
* env: {
* IMPORTED_VAR: step1.exportedVariable('MY_VAR'),
* },
* commands: ['echo $IMPORTED_VAR'],
* });
*/
public exportedVariable(variableName: string): string {
if (this.exportedVarsRendered && !this.exportedVariables.has(variableName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,19 @@ export abstract class CodePipelineSource extends Step implements ICodePipelineAc
* - `RegistryId`
*
* @see https://docs.aws.amazon.com/codepipeline/latest/userguide/reference-variables.html#reference-variables-list
* @example
* // Access the CommitId of a GitHub source in the synth
* const source = pipelines.CodePipelineSource.gitHub('owner/repo', 'main');
*
* const pipeline = new pipelines.CodePipeline(scope, 'MyPipeline', {
* synth: new pipelines.ShellStep('Synth', {
* input: source,
* commands: [],
* env: {
* 'COMMIT_ID': source.sourceAttribute('CommitId'),
* }
* })
* });
*/
public sourceAttribute(name: string): string {
return makeCodePipelineOutput(this, name);
Expand Down