Skip to content

Unexpected CodePipline Variable Resolution Error (Bug?)

1

I am using variables to pass information about the current commit from one pipeline stage to the next (awesome, by the way).

However, if the commit contains a double quote ("), then my pipeline fails to execute with an error about formatting:

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 unresolved EnvironmentVariables configuration is:

[{"name":"COMMIT_INFO_MESSAGE","value":"#{GitInfoEx.COMMIT_INFO_MESSAGE}","type":"PLAINTEXT"}]

And the resolved value is:

[{"name":"COMMIT_INFO_MESSAGE","value":"e488306 Revert "AP-1715-team-chkbox-issue (#657)"","type":"PLAINTEXT"}]

Notice the double quote around AP-1715-team-chkbox-issue (#657). They are not escaped. I would expect CodePipeline to escape values for me.

Is this a bug or by design?

asked 5 years ago1.3K views
3 Answers
0

Any chance someone could answer this?

answered 5 years ago
0

Hi m4dc4p,

It sounds like in your use-case you are trying to pass a variable to a CodeBuild Action through Environment variables. I was able to replicate this issue. Unfortunately, due to having a multitude of integrators (both first and third-party), we don't escape special characters at this moment.

Being able to escape special characters sounds like a feature that would benefit a variety of customers. Therefore, I've made a note of your interest on our internal feature request.

In the meantime, I would suggest preprocessing variables individually in a Lambda action and then referencing those processed variables in the CodeBuild action.
https://docs.aws.amazon.com/codepipeline/latest/userguide/action-reference-Lambda.html

Thank you.

answered 5 years ago
0

Been a while but have noticed that this problem still persists and can't use the default environment variables that pick the COMMIT messages if special characters or even new line characters exist in the commit message.

There is a workaround

- COMMIT_MESSAGE=$(aws codepipeline list-pipeline-executions  --pipeline-name <Pipeline_Name> --max-items 1 | jq -r '.pipelineExecutionSummaries[0].sourceRevisions[0].revisionSummary')

Reference from here: https://stackoverflow.com/questions/61163037/aws-codebuild-environmentvariables-specified-in-action-config-does-not-match-e

answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.