aws-cdk: commit_message causes an incorrect environment variable
While using the cdk to create a codepipeline that has a github source action I would like to pass the environment variables down to subsequent steps.
self.source_variables = {
"AUTHOR_DATE": codebuild.BuildEnvironmentVariable(value=self.source_action.variables.author_date),
"BRANCH_NAME": codebuild.BuildEnvironmentVariable(value=self.source_action.variables.branch_name),
"COMMIT_ID": codebuild.BuildEnvironmentVariable(value=self.source_action.variables.commit_id),
# "COMMIT_MESSAGE": codebuild.BuildEnvironmentVariable(value=self.source_action.variables.commit_message),
"COMMITTER_DATE": codebuild.BuildEnvironmentVariable(value=self.source_action.variables.committer_date),
"COMMIT_URL": codebuild.BuildEnvironmentVariable(value=self.source_action.variables.commit_url),
"REPOSITORY_NAME": codebuild.BuildEnvironmentVariable(value=self.source_action.variables.repository_name),
}
However, if the line for commit_message is not commented out then I am met with an error that says the format is wrong: should be [{name, type, value}]
EnvironmentVariables specified in action config does not match expected format, the expected format is JSON array adhering to the following format: [{“name”: “string”, “type”: “string”, “value”: “string”}]
the issue is not present with any other value.
Reproduction Steps
Create a simple codepipeline with a GithubSourceAction and a codebuild action like:
self.build_init_action = actions.CodeBuildAction(
action_name="initialize",
project=build_project,
input=self.source,
outputs=[],
environment_variables=self.source_variables
)
The deploy command will succeed but the details for the second stage will not work with the commit_message.
Error Log
No Errors except when in the console.
EnvironmentVariables specified in action config does not match expected format, the expected format is JSON array adhering to the following format: [{“name”: “string”, “type”: “string”, “value”: “string”}]
Environment
- CLI Version : 1.45
- Framework Version: 1.45
- Node.js Version: v14.3.0
- OS : manjaro linux and mac osx
- Language (Version): python 3.8.3
This is 🐛 Bug Report
It is equally as likely that I am just missing something wildly dumb.
I can provide cf templates at request.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 19 (8 by maintainers)
Hey @MisterBianco ,
I’ve talked to the CodePipeline team, and unfortunately I don’t have good news 😕 . This is a known issue - apparently the escaping for CodePipeline Variables is incorrect for some action configurations, and CodeBuild environment variables are one of those. So basically, right now, the best advice I can give is to just not use the
commitMessagevariable with conjunction with CodeBuild environment variables.If you pay for AWS support, you can open an issue about this, but I can’t guarantee when it will be fixed from the CodePipeline side.
Sorry I don’t have better news for you. I’m resolving this one, please let us know if you need anything else from our side for this problem.
Thanks, Adam
OK. So this is a CodePipeline issue then. I’ll get in contact with the team.
It succeeded.
I wonder whether there’s some character(s) in the message that make CodePipeline choke on it.
Can you try a simple experiment for me? Can you try committing and pushing an empty commit with a very simple
error(EDIT: obviously meant commit) message that for sure doesn’t contain any special characters? Something like:and see if you get the same error in the CodeBuild Action? (Make sure the deployed version of the CodePipeline is the one that has this error, so with the line
"COMMIT_MESSAGE": codebuild.BuildEnvironmentVariable(value=self.source_action.variables.commit_message)present).Thanks, Adam
This is still a problem today. Passing a commit message to a codebuild action is more than frequent.
Hey @skinny85 ! Are you aware of any fix that went in for this (before I try now)?