How to install firebase extension in not-interactive way

Viewed 618

I am trying to install firebase firestore-bigquery-export extension through firebase CLI. But I can not find how I can install an extension in non-interactive way.

I need that because I have multiple environments and CI.

The console contains information about , but where I can find parameters name?

$ firebase ext:install firestore-bigquery-export -h
Usage: firebase ext:install [options] [extensionName]

install an official extension if [extensionName] or [extensionName@version] is provided; or run with `-i` to see all available extensions.

Options:
  --params <paramsFile>  name of params variables file with .env format.
  -h, --help             output usage information

Thank you for your help!

2 Answers

As explained here in the doc (expand the "Bypass the interactive terminal prompts for parameter values during installation" section), you need to :

  1. Create a .env file (for example, params.env) that defines your parameter values. Save the file locally.
  • Declare each parameter by its param value found in the extension's extension.yaml file.
  • Include values for all the parameters.
  • Follow dotenv syntax.
  1. Run the extension-install command with the --params flag. For example, to install the Translate Text extension, run the following command: firebase ext:install firestore-translate-text --params=path/to/params.env --project=projectID-or-alias

To find the extension.yaml file for a given extension, you need to view its source code. To find a link to the source code for one the official Firebase extensions, you need to click "Learn more" on the extension's card on the Firebase Extensions product page or in the Firebase console.

In response to aponski's comment here re: installing multiple instances of extension...

And to add a little to the answer provided by Renaud Tarnec....

I found the following worked for me when trying to install multiple instances of the firestore-bigquery-export extension via the firebase cli non-interactively.

Notably I needed to add the --force flag (not mentioned in the doc unless I'm missing something) and pipe the extension id as this is not available in the extension.yaml file.

#!/bin/bash

PROJECT_ID=$1
DIR="$(cd "$(dirname "$0")" && pwd)"
echo $PROJECT_ID

echo "firestore-bigquery-exports-users" | \
  firebase ext:install firebase/firestore-bigquery-export \
  --params=$DIR/users.params.env \
  --project=$PROJECT_ID \
  --force

echo "firestore-bigquery-exports-events" | \
  firebase ext:install firebase/firestore-bigquery-export \
  --params=$DIR/events.params.env \
  --project=$PROJECT_ID \
  --force
Related