问题描述
我是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
解决方法
我找到了解决方案 我不知道我必须将环境变量添加到Google Cloud Function中。 现在一切都按预期运行