0

My objective is to serve firebase functions in my CI process, (and then run e2e tests).

So in dev I can do this, assuming I am already logged in:

firebase serve --only functions --port=9000 --project=<project_id>

However, in CI I am not logged in, and I therefore tried doing this:

firebase serve --only functions --port=9000 --project=<project_id> --token=<firebase-ci-token>

However this does not work - should it not be possible?

Update

I am now trying to run:

export FIREBASE_TOKEN=<firebase-token>

and then

firebase serve --only functions --port=9000 --project=eddystone-test-e4cd3

but it gives me some error (in the firebase-debug.log):

TypeError: Cannot read property 'refresh_token' of undefined

DauleDK
  • 3,313
  • 11
  • 55
  • 98
  • According to [these docs](https://github.com/firebase/firebase-tools#using-with-ci-systems) all commands should indeed take a `--token` flag. It might be a bug, although I fear it may well be a *documentation* bug. Can you try putting the token in the `FIREBASE_TOKEN` environment variable? – Frank van Puffelen Mar 14 '18 at 14:20
  • HI @FrankvanPuffelen - thanks for the suggestion. It gives a new error. Maybe I should open an issue on the firebase functions github? – DauleDK Mar 14 '18 at 16:51
  • Does this look like your issue? https://github.com/firebase/firebase-tools/issues/364 – laurenzlong Mar 14 '18 at 18:13
  • yes - so full path to GOOGLE_APPLICATION_CREDENTIALS is the current work-around? – DauleDK Mar 14 '18 at 18:21

1 Answers1

0

Here's an example .gitlab-ci.yml of what you may need. Note that the token generated by firebase login:ci is specified on each firebase command:

deploy:functions:staging:
    stage: deploy_functions
    environment: staging
    only:
        - staging
    when: manual
    script:
        - cd $APP_PATH/functions
        - npm install
        - cd ..
        - echo $ENVIRONMENT_STAGING >> $APP_PATH/src/environments/environment.staging.ts
        - firebase use staging --token "$FIREBASE_CI_AUTH_TOKEN"
        - firebase functions:config:set dev.authkey="$FIREBASE_CONFIG_DEV_AUTHKEY" --token "$FIREBASE_CI_AUTH_TOKEN"
        - firebase deploy --only functions --token "$FIREBASE_CI_AUTH_TOKEN" -P <project>
Gus
  • 6,545
  • 4
  • 36
  • 39