Firebase and Gitlab continuous integration pipeline failing - firebase

I am trying to hook up a simple static website to firebase hosting from Gitlab using their continuous integration tab. After downloading and installing firebase command line tools I am here:
stages:
- deploy
deploy-prod:
stage: deploy
only:
- master
script:
- firebase use <project-name> --token $FIREBASE_TOKEN
- firebase deploy --only hosting -m "Pipe $CI_PIPELINE_ID Build $CI_BUILD_ID" --token $FIREBASE_TOKEN
After that in firebase I deploy the site. However, gitlab then reports that the job is not deployed because
Error: firebase use must be run from a Firebase project directory.
Run firebase init to start a project directory in the current folder.
I dont understand the error, as I have in fact run firebase in the project director. Or is the error referring to the image thats in the yml file?
Either way, could someone please help me out? I've found a number of blog posts using CI in gitlab with firebase but I am stuck.

I got same issue and solved it by check folder structure
in my case:
/root/xx_project
firebase.json is in xx_project
so I need to cd xx_project

Related

Firebase server side rending example for nuxt.js

I have created small nuxtjs app using firebase. I'm having hard time setting up nuxtjs build with firebase cloud function. I found this video but it is outdated (https://www.youtube.com/watch?v=ZYUWsjUxxUQ&list=PLl-K7zZEsYLkbvTj8AUUCfBO7DoEHJ-ME&index=9).
Any help or guidance or documentation would be helpful.
Here is link for the repo which. Also I mentioned steps which I tried to follow.
https://github.com/bhargavkonkathi/nuxt-ssr
Here are the things that I've tried with this repo:
1. Install dependencies inside src using yarn install
2. Install dependencies in functions folder
3. Run yarn build inside src it will create nuxt folder inside folder.
4. Copy and move all contents from functions/nuxt/dist/client folder to public/client folder.
5. Now run functions serve --only functions,hosting -p 5004
6. You should see build firebase hosting running and build running.
7. Deploy firebase deploy --only functions,hosting.
This is the link which I able to deploy after it is running. As you can see vuetify is not working properly. I'm getting few issues.
Deployed link
https://ssr-bumps-testing.web.app/

Is it possible to only deploy specific Firebase functions that changed with GitLab CI/CD?

Deploying all Firebase functions at once is quite easy with GitLab CI/CD (How to leverage GitLab CI/CD for Google Firebase):
deploy-functions:
stage: deploy
script:
- cd functions
- npm install
- cd ..
- firebase deploy --only functions --token $FIREBASE_TOKEN
only:
refs:
- master
changes:
- functions/**/*
However, when "deploying large numbers of functions, you may exceed the standard quota and receive HTTP 429 or 500 error messages. To solve this, deploy functions in groups of 10 or fewer." (see Manage functions deployment and runtime options).
With the Firebase CLI, specific functions (e.g. addMessage and makeUppercase) can be deployed using firebase deploy --only functions:addMessage,functions:makeUppercase.
Now, is there an easy way to automatically detect which functions are affected by changes in the code base and build a gitlab-ci.yml that only deploys the corresponding functions?

Google Cloud Build & Firebase Deploy - "An unexpected error has occurred"

I'm using Google Cloud Build to do a deployment to Firebase Hosting when a commit is on master. I'm using the Firebase Cloud Builder, deployed to my project. I've checked permissions in the Cloud Console and Firebase access is enabled.
Everything seems to go well in generating the static HTML for hosting, but at the final build step it fails suddenly with this problem:
Error: An unexpected error has occurred.
Here is the step in my cloudbuild.yaml that fails:
- name: gcr.io/$PROJECT_ID/firebase
args: ['deploy', '--project', '$PROJECT_ID']
id: Deploy to Firebase
The last time that I installed the container was in October. The "An unexpected error has occurred" was solved by others by updating their version of the Firebase CLI. I had to do the same thing in my CD environment in order to get this to work.
Following these instructions in the README:
cd cloud-builders-community/firebase
gcloud builds submit --config cloudbuild.yaml .
The Firebase CLI version was reinstalled and published to my project. Then I was able to retry the build and it worked successfully.
This tripped me up for about an hour yesterday, and I thought it may be helpful to just have the answer documented somewhere.

Where to run gcloud init?

Need to access some gcloud functions in a react project. Should I run gcloud init in the project root folder or within the firebase functions/ folder? Will it interfere with firebase deploy for the functions?
Following this: https://medium.com/#nedavniat/how-to-perform-and-schedule-firestore-backups-with-google-cloud-platform-and-nodejs-be44bbcd64ae
I already have some other firebase functions set up which I would deploy with firebase deploy --only functions. When I got to step 5 of the above tutorial, I got a gcloud command not found. I followed the instructions here: https://cloud.google.com/sdk/docs/#install_the_latest_cloud_tools_version_cloudsdk_current_version
and when it got to step 5 in that, I presume I should be doing it somewhere in the project folder to use that project's specific login? Without running it I get the following error when trying to use:
gcloud functions deploy backup --runtime nodejs8 --trigger-topic YOUR_TOPIC_NAME_HERE
ERROR: (gcloud.functions.deploy) Error parsing [name].
The [function] resource is not properly specified.
Failed to find attribute [project]. The attribute can be set in the following ways:
- provide the argument [--project] on the command line
- set the property [core/project]
The error message is clear. Add --project <project id> at the deploy command or perform a gcloud config set project <project id>.
If you use only firebase, firebase has automatically create a GCP project. Go to https://console.cloud.google.com to view your project name or ID. I think it's also possible to view this information in firebase console.

`firebase deploy` just hangs

I'm trying to deploy a site to firebase.
firebase init worked fine. I then ran firebase bootstrap and chose the tetris template. So far so good. But when I run firebase deploy I get Preparing to deploy Public Directory... and then it just hangs forever.
How can I figure out what's going wrong?
Random info in case it helps:
My firebase-tools is version 1.0.1; node is version 0.8.20; npm is version 1.4.23. I ran sudo npm install -g firebase-tools to get the CLI. I'm running on a debian chroot on Android 4.4.3 device. My wifi works fine. On a lark I even tried running sudo firebase deploy in case it depends on ICMP packets or something, but there was no difference.
Firstly, the main reason it's not working is that Node.js version 0.10 or greater is required.
However, even once you've upgraded Node (and I'd recommend getting the latest of firebase-tools too) you're likely to be attempting to deploy the directory that you ran the initial firebase init command from, or at least the folder you specified in the setup (which defaults to the folder you ran the command from).
You should change directory and run the firebase deploy command from the folder that was created by the bootstrap command - which would have been named after the name of the Firebase it was created with, and you can delete the firebase.json file created in the parent directory.
The reason is that firebase init and firebase bootstrap are two different ways of doing the same thing - getting a folder in a deployable state. firebase init is for existing projects with files that will eventually be deployed, and firebase bootstrap is for creating a project from one of the existing templates. By running both, the initial firebase init would have created a firebase.json file containing the settings specified by the prompts, and then the firebase bootstrap command would have created a whole new sub-folder with its own firebase.json for the different settings.

Resources