[@aws-cdk/pipelines] - Can't get the Commit SHA
See original GitHub issueWhen using GitHubSourceAction
we should be able to get the “sha” of the commit that triggered the action. The TypeScript shows that it should be available under variables.commitId
.
However, in my pipeline, it’s just giving me a template variable (or something like that): #{Source_GitHub_NS.CommitId}
Reproduction Steps
The code looks like this:
const sourceAction = new cpa.GitHubSourceAction({
actionName: "GitHub",
output: sourceArtifact,
oauthToken: cdk.SecretValue.secretsManager("github-repo-token"),
owner: "github-username",
repo: "the-repo",
branch: "dev",
})
const sha = sourceAction.variables.commitId // returns #{Source_GitHub_NS.CommitId}
How can we get the actual SHA in this scenario?
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:13 (4 by maintainers)
Top Results From Across the Web
Get source repo commit hash in AWS code build step
Found a solution that works for me: PIPELINE_EXECUTION_ID=$(aws codepipeline get-pipeline-state --region ${AWS_REGION} --name my-pipeline ...
Read more >aws-cdk/aws-codepipeline-actions module
When you want to have multiple inputs and/or outputs for a Project used in a Pipeline, instead of using the secondarySources and secondaryArtifacts...
Read more >aws-cdk/pipelines module - AWS Documentation - Amazon.com
The reason is that the pipeline will start deploying and self-mutating right away based on the sources in the repository, so the sources...
Read more >Environment variables in build environments - AWS CodeBuild
If CodePipeline is not able to resolve the source revision, such as when the source is an Amazon S3 bucket that does not...
Read more >Building, bundling, and deploying applications with the AWS ...
The post CDK Pipelines: Continuous delivery for AWS CDK applications ... Because we don't commit the Go executable to our source repository, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey @arpowers ,
thanks for opening the issue. The commit is only available during Pipeline execution, as it changes each time you push something to your repository. That’s why it’s available as this
#{Source_GitHub_NS.CommitId}
expression. You can pass it to a different thing in your pipeline - for example, the environment variables of your CodeBuild Project:And then read the
COMMIT_ID
environment variable when executing the build.Hope this clears this up!
Thanks, Adam
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.