简体   繁体   中英

How to use CircleCI Environment Variables in Firebase Functions

I'm new to Continous Intregration and recently I setup my first project in CircleCI. Unfortunately I seems like it's not completely working as expected.

I want to deploy my application to Firebase (Hosting and Functions). Of course I added Environment Variables to the project in CircleCI.

But Firebase Functions doesn't access my Environment Variables so it's running into errors.

In the Functions folder I created a new nodejs application incl. the dotenv package and I'm calling the variables with process.env.CIRCLECI_VARIABLE.

Would be great if someone could give me a hint what's missing.

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

I've found the solution I didn't know that I have to add the Environment Variables to the Google Cloud Function. Now everything is working as expected

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM