Suppose having a project in a bitbucket repository storing a secret API key in a config file like config.json:
{
"secret":
}
Is it possible refer to the "secret" variable from variables in bitbucket pipeline and then deploy this automatically to google App Engine, so that App Engine "knows" the secret variable?
Suppose having a project in a bitbucket repository storing a secret API key in a config file like config.json:
{
"secret":
}
Is it possible refer to the "secret" variable from variables in bitbucket pipeline and then deploy this automatically to google App Engine, so that App Engine "knows" the secret variable?
Share Improve this question edited Apr 6, 2020 at 20:08 David asked Apr 6, 2020 at 0:22 DavidDavid 3,0866 gold badges39 silver badges89 bronze badges1 Answer
Reset to default 6 +50You can use envsubst
mand in your pipeline.
Your json file would look like this and be named config_template.json
:
{
"secret": $SECRET
}
The step in your pipline would look like this:
- 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!
This assumes that you have envsubst
in your build image and a repository variable called SECRET
in your pipeline.