假设在bitbucket存储库中有一个项目,它在配置文件中存储了一个秘密的API key,比如config.json:
{
"secret":
}
有没有可能引用bitbucket管道中的变量中的“秘密”变量,然后自动将其部署到google App Engine,以便App Engine“知道”该秘密变量?
发布于 2020-04-08 14:07:25
您可以在管道中使用envsubst
命令。
您的json文件将如下所示,并命名为config_template.json
{
"secret": $SECRET
}
管道中的步骤将如下所示:
- step:
name: replace secret
script:
# pipe config_template.json to envsubst and store result in a file called config.json
- cat config_template.json | envsubst > config.json
# show config.json TODO: Remove this when you are sure it is working!
- cat config.json
# Deploy config.json to App Engine here!
这里假设构建映像中有envsubst
,管道中有一个名为SECRET
的存储库变量。
https://stackoverflow.com/questions/61051224
复制