0

In one of my projects experimenting Circle CI with Firebase. In order to use the firebase command for deployment purposes first the firebase-tools needs to be installed.

In my config.yml file the following stands - simplified:

version: 2.1
orbs:
  node: circleci/node@1.1.6
jobs:
  install-and-build:
    executor:
      name: node/default
    steps:
      - node/with-cache:
          steps:
            - checkout
            - run: npm install
            - run: sudo npm install -g firebase-tools
            - run: npm run-script build
  deploy:
    executor:
      name: node/default
    steps:
      - node/with-cache:
          steps:
            - run: firebase --version
workflows:
  build-and-deploy:
    jobs:
      - install-and-build:
          requires:
            - install-dependencies
      - deploy:
          requires:
            - install-and-build

Issue:

Once the npm install -g firebase-tools command is in different step then it does not recognize the firebase command lately and throws the following error:

/bin/bash: firebase: command not found

I found a solution which eliminates the issue by moving the firebase-tools install step before usage as:

- node/with-cache:
    steps:
      - run: sudo npm install -g firebase-tools
      - run: firebase --version

Questions:

I would say that solution is just a workaround instead of a proper one like moving the firebase-tools installation steps into the install-and-build one and using in the deployment step. I tried already the following ideas firstly based on my research:

  1. Creating an alias as alias firebase="`npm config get prefix`/bin/firebase" based on this SO question.
  2. Running npm get prefix to figure out which folder is containing the firebase command based on this SO question.
  3. Installing firebase-tools as a devDependency and using save_cache and restore_cache option to read from node_modules folder.

Probably the issue is something else what I don't see, none of them helped that much thus my questions:

  1. Is there any solution which helps the pipeline accessing the firebase command after installed in any previous steps?
  2. Is it fine to have the firebase-tools installation step in the deployment step? For some reason I don't like that.

Could someone enlighten me about this topic? Any idea is appreciated, thank you!

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
norbitrial
  • 14,716
  • 7
  • 32
  • 59
  • Why don't you want to install it in the same job where it's being used? The jobs are running in different containers, you shouldn't expect them to share state outside the workspace. – jonrsharpe May 21 '20 at 19:52
  • @jonrsharpe Interesting, that explains why I cannot run once installed in different workspace. For some reason I wanted to do all the installation in one step and using the tool later but most probably that does not make to much sense in this term. – norbitrial May 21 '20 at 20:18
  • 1
    See https://circleci.com/docs/2.0/concepts/#caches-workspaces-and-artifacts - you could persist it to the workspace, but it'd be much more straightforward to install as needed. – jonrsharpe May 21 '20 at 20:20
  • So the suggestion would be to go with the shared working solution, no need to separate the installation from the usage of `firebase-tools`. Thanks for the clarification! – norbitrial May 21 '20 at 20:23

1 Answers1

0

In order to get firebase tools up and running in my circleci. I used the following:

  # Install Firebase tools needed for firebase emulator
  - run:
      name: Install firebase tools
      command: |
        curl -sL firebase.tools | bash
  # Then start firebase emulator in the background
  - run:
      name: Start firebase emulator
      command: |
        firebase emulators:start --import=driver_app_data/export_directory
      background: true
Haider Malik
  • 1,581
  • 1
  • 20
  • 23