aws / aws/aws-cdk

pipelines.CodePipelineSource.sourceAttribute() can be only called from synth step

Open
#20,643 3 comments 6 reactions 1 assignee Claimed by @TheRealAmazonKendra View on GitHub
@aws-cdk/pipelines bug effort/medium p1
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

This is follow-up issue to earlier issue #19184.

It seems that accessing the pipeline source variables only works from the Pipeline synth step. If you call the sourceAttribute() method from any CodeBuildStep later in the pipeline chain, you get the mentioned error.

### Expected Behavior

I expected that I can access source variables in any step of the pipeline or even set them as default variables.

This should work:

```
pipeline.addWave('test', {
pre: [
new CodeBuildStep('test', {
commands: [],
buildEnvironment: {
environmentVariables: {
'COMMIT_ID': {value: source.sourceAttribute('CommitId')}
}
}
})
]
});
```

Also this should be possible, setting them as default for all CodeBuild steps:

```
codeBuildDefaults: {
buildEnvironment: {
environmentVariables: {
'COMMIT_ID': {value: source.sourceAttribute('CommitId')},
}
}
}
```

### Current Behavior

Following error is generated while cdk synth:

t`hrow new Error(`Output for step ${this.step} not configured. Either the step is not in the pipeline, the step implementation did not call 'this.discoverReferencedOutputs()', or this engine does not support Outputs for this step.`);`

### Reproduction Steps

See code examples above.

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### CDK CLI Version

2.27

### Framework Version

_No response_

### Node.js Version

v16 LTS

### OS

macOS or Linux

### Language

Typescript

### Language Version

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.