Skip to content
Advertisement

Trying to run Firestore emulator on Gitlab CI pipeline gives “java is not installed” error

When trying to run Firestore emulator in a Gitlab CI/CD pipeline I get the following error:

Firestore Emulator has exited because java is not installed, you can install it from https://openjdk.java.net/install/

The question is, how do I install java in this env? I found a similar post, but there’s no mention of the need of installing java, so I’m wondering if I’m missing something obvious.

This is how my .gitlab-ci.yml file looks like:

image: node:14.15.4

cache:
  paths:
  - functions/node_modules/
  - project_name/node_modules/

before_script:
  - npm i -g firebase-tools

.test_and_deploy:
  script:
    - cd functions    
    - npm i 
    - cd ..
    - cd project_name
    - npm i
    - cd ..

    - cd functions
    - npm run build
    - firebase emulators:exec -P project_name --only firestore "npm run test-once" 
    - cd ..
    
    - cd project_name    
    - cp .env.project_name.local .env    
    - npm run build
    
    - firebase --project project_name deploy

Advertisement

Answer

I was finally able to figure out how to install java in the docker image, now this part of the script in the yml file looks like this:

.test_and_deploy_functions:
  script:
    # this step installs java, necessary for the firebase emulator
    - apt-get update && apt-get install -y openjdk-8-jdk
    - cd functions    
    - npm i 
    - npm run build
    - firebase use project_name
    - firebase emulators:exec --only firestore "npm run test-once" 
    - npx firebase deploy --only functions
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement