如何在Firebase函数中使用CircleCI环境变量

问题描述

我是Continent Intregration的新手,最近我在CircleCI中设置了我的第一个项目。 不幸的是,我似乎无法完全按预期工作。

我想将我的应用程序部署到Firebase(托管和功能)。 当然,我在CircleCI中向项目添加了环境变量。

但是Firebase Functions无法访问我的环境变量,因此会遇到错误。

在Functions文件夹中,我创建了一个新的包含nodejs的应用程序。 dotenv程序包,我用process.env.CIRCLECI_VARIABLE调用变量。

如果有人可以给我提示缺少的内容,那将很棒。

config.yml

version: 2.1

jobs:
  build:
    docker:
      - image: circleci/node:10
    steps:
      - checkout
      - run:
          name: Install packages
          command: yarn install
      - run:
          name: Build project
          command: yarn build
      - run:
          name: Install functions packages
          command: cd ./functions && yarn install
  deploy:
    docker:
      - image: circleci/node:10
    steps:
      - checkout
      - run:
          name: Install packages
          command: yarn install
      - run:
          name: Build project
          command: yarn build
      - run:
          name: Install functions packages
          command: cd ./functions && yarn install
      - run:
          name: Installing Firebase-Tools
          command: yarn add firebase-tools
      - run:
          name: Firebase Deploy
          command: ./node_modules/.bin/firebase deploy --token "$FIREBASE_TOKEN"
workflows:
  build_and_deploy:
    jobs:
      - build
      - deploy:
          requires:
            - build
          filters:
            branches:
              only: master

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)