Search code examples
firebasegoogle-cloud-platformcontinuous-integrationtravis-cifirebase-cli

How to skip `(Y/n)` prompt when running firebase login


I am trying to set up firebase CLI in my continuous integration (travis-ci, not that it really matters) and I inevitably have to login to firebase.

$ firebase login --token FIREBASE_TOKEN --no-localhost
]0;Firebase CLIi  Firebase optionally collects CLI usage and error reporting information to help improve our products. Data is collected in accordance with Google's privacy policy (https://policies.google.com/privacy) and is not used to identify you.
? Allow Firebase to collect CLI usage and error reporting information? (Y/n) 

Since it's just travis-ci, there's no way for it to answer yes or no to that prompt, which hangs and kills the build.

I did check firebase login's --help and here's what I got:

> firebase login --help
Usage: firebase login [options]

log the CLI into Firebase

Options:
  --no-localhost  copy and paste a code instead of starting a local server for authentication
  --reauth        force reauthentication even if already logged in
  -h, --help      output usage information

So there doesn't seem to be any kind of override flag like -y or anything.

How am I supposed to log into firebase in my continuous build if there's no way to skip this prompt? Alternatively, how can I skip this prompt?

I think it can't be complicated because support for "CI Systems" is outlined in Firebase's own docs.

Edit: Attempted with login:ci

$ firebase login:ci --token $FIREBASE_TOKEN
]0;Firebase CLI
Visit this URL on this device to log in:
https://accounts.google.com/o/oauth2/auth?client_id=...
Waiting for authentication...

Solution

  • You don't need to firebase login if you run commands with the flag --token.

    $ curl -sL https://firebase.tools | bash
    -- Checking for existing firebase-tools on PATH...
    -- Checking your machine type...
    -- Downloading binary from https://firebase.tools/bin/linux/latest
    ######################################################################## 100.0%
    -- Setting permissions on binary...
    -- Checking your PATH variable...
    -- firebase-tools@]0;Firebase CLI8.4.1 is now installed
    -- All Done!
    before_install.2
    $ firebase firestore:delete --token $FIREBASE_TOKEN --all-collections --project $PROJECT_ID -y
    ]0;Firebase CLIDeleting the following collections: