最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Storing secrets into Bitbucket Pipelines and then deploy on App Engine? - Stack Overflow

programmeradmin3浏览0评论

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 badges
Add a ment  | 

1 Answer 1

Reset to default 6 +50

You 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.

发布评论

评论列表(0)

  1. 暂无评论