LoginSignup
0
0

More than 3 years have passed since last update.

CodePipelineでSourceVariablesからGitのCommitMessageを環境変数として注入するときにハマった

Posted at

CodePipelineをGitのWebhookで起動した際、SourceVariablesにはコミットIDやメッセージなどの様々なものが含まれています
参考⇢https://docs.aws.amazon.com/ja_jp/codepipeline/latest/userguide/actions-variables.html

このコミットメッセージを、CodeBuildへ環境変数として渡したいときにCodepipelineのBuildステージに以下の設定をしました
image.png

これでSourceステージで出力されているCommitMessageを環境変数に注入できるはずでした
ところがPipelineを実行すると、
EnvironmentVariables specified in action config does not match expected format,~~~
というエラーがPipeline出てしまい、そもそもBuildステージが開始されません。

調べたところ、どうやらコミットメッセージに「'」(シングルクオート)が入っている場合、文字列として適切に認識されずにエラーになってしまうようです。
参考⇢https://forums.aws.amazon.com/thread.jspa?threadID=314707

例えばPRをマージした際のコミットメッセージは
Merge branch 'develop' into feature/atarasiikinoudaYO
の様になっている(シングルクオートが含まれている)事が多いため、失敗してしまします。

そのため、このような運用をする際はPipelineに検知される部分のコミットメッセージは「'」の無いように書き換えると、しっかりと環境変数へ注入されます。

CodeBuildへ注入された環境変数↓
image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0