Docker Bitbucket-pipeline.yml不读取我的Heroku环境变量

Docker Bitbucket-pipeline.yml不读取我的Heroku环境变量,docker,continuous-integration,bitbucket,bitbucket-pipelines,heroku-ci,Docker,Continuous Integration,Bitbucket,Bitbucket Pipelines,Heroku Ci,当我通过bitbucket回购推送到master时,我想将我的应用程序部署到HEROKU。我有bitbucket-pipeline.yml文件设置,它似乎没有任何语法错误 但是在读取我的$HEROKU_API_密钥时,构建失败。这个键在我的.env文件中,当我从index.js文件记录它时,它会记录到控制台 唯一可行的选择是复制api键并将其粘贴到该行中。但我真的不想这么做 我目前在Ubuntu 18.04 LTS和节点v10.16.3上 我如何解决这个难题 这是yml文件 这是构建结果 您应该

当我通过bitbucket回购推送到master时,我想将我的应用程序部署到HEROKU。我有bitbucket-pipeline.yml文件设置,它似乎没有任何语法错误

但是在读取我的$HEROKU_API_密钥时,构建失败。这个键在我的.env文件中,当我从index.js文件记录它时,它会记录到控制台

唯一可行的选择是复制api键并将其粘贴到该行中。但我真的不想这么做

我目前在Ubuntu 18.04 LTS和节点v10.16.3上

我如何解决这个难题

这是yml文件 这是构建结果
您应该使用存储库设置中的存储库变量来存储环境变量。我认为Bitbucket管道无法处理.env文件。您可以在此处找到有关使用管道环境变量的更多详细信息。

我找到了解决方案。bitbucket从在线存储库设置环境变量,它不使用本地repo中的本地环境变量

要访问它,您必须转到存储库->设置->部署

Bitbucket提供3种默认构建环境: -测试 -登台 -生产

您可以为上述任何环境添加环境变量


感谢Alexander Zhukov提供的提示。

谢谢,我找到了它,bitbucket中有一个部署设置部分,允许您输入环境变量。
# This is a sample build configuration for JavaScript.
# Check our guides at https://confluence.atlassian.com/x/14UWN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: node:10.15.3

pipelines:
  default:
    - step:
        name: Defaults
        caches:
          - node
        script: # Modify the commands below to build your repository.
          - npm install
          - npm test
    - step:
        name: create artifact
        script:
          - mkdir artefacts
          - tar -czf artefacts/my-app-$BITBUCKET_BUILD_NUMBER.tar.gz --exclude=./artefacts .
          - cp artefacts/* .
        artifacts:
          - my-app-*.tar.gz
    - step:
        name: Deploy to production
        deployment: production
        script:
          - pipe: atlassian/heroku-deploy:1.0.1
            variables:
              HEROKU_API_KEY: $HEROKU_API_KEY
              HEROKU_APP_NAME: "my-app"
              ZIP_FILE: "my-app-$BITBUCKET_BUILD_NUMBER.tar.gz"
              WAIT: "true" # Optional.
              DEBUG: "false" # Optional