Where to run gcloud init? - firebase

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.

Related

Firebase and Gitlab continuous integration pipeline failing

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

Error while deploying environment variable to firebase

When I am triying to add environment variable to firebase, I have the following error when doing firebase deploy --only functions
Error: Cannot understand what targets to deploy. Check that you specified valid targets if you used the --only or --except flag. Otherwise, check your firebase.json to ensure that your project is initialized for the desired features
I can't understand why i have this error (I previously managed to add environment variable on the same project)
Note : I have also tried add environment variable to a newly created project so my firebase.json is not empty
Check that where you are running the command firebase deploy --only functions in command prompt is under the same directory as your functions folder.

'Firebase init' command didn't create package.json, index.js and function folder

I’m now trying to create a tutorial app for my Google Home but I faced some trouble. According to this tutorial, I finished following steps of Build fulfillment.
1.Download and install Node.js.
2.npm install -g firebase-tools
3.firebase login
4-1.mkdir sillynamemaker
4-2.cd sillynamemaker
4-3.firebase init
5.select Functions:…
6.select action project(silllynamemaker-***)
7.firebase init
But after step 7, there were only ‘firebase.json’ in current folder, so I couldn’t see functions folder, package.json and index.js.
My console log is below.
$ node -v
v8.6.0
$ npm --version
5.3.0
$ firebase --version
3.13.1
$ firebase init
You're about to initialize a Firebase project in this directory: ~/ghome/sillynamemaker
? Which Firebase CLI features do you want to setup for this folder? Press Space to select features, then Enter to confirm your choices.
⚠ You have have not selected any features. Continuing will simply associate this folder with a Firebase project. Press Ctrl + C if you want to start over.
=== Project Setup
First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,
but for now we'll just set up a default project.
? Select a default Firebase project for this directory: SillyNameMaker (sillynamemaker-*****)
i Writing configuration info to firebase.json...
i Writing project information to .firebaserc...
✔ Firebase initialization complete!
I'm really glad if someone help me.
Thanks in advance.
You must select features you want to initialize by using the arrow keys and spacebar -- none are on by default. See the error message in your pasted log:
⚠ You have have not selected any features. Continuing will simply associate this folder with a Firebase project. Press Ctrl + C if you want to start over.
You can also run firebase init functions to specifically initialize only functions.

gcloud deploy fails on a weired "Access to project ID trainer-messenger-server is denied"

I followed the docs and entered:
$ gcloud beta functions deploy helloWorld --stage-bucket serverless-example-bucket1 --trigger-http
and I get:
ERROR: (gcloud.beta.functions.deploy) ResponseError: status=[403], code=[Forbidden], message=[Access to project ID trainer-messenger-server is denied]
What is this trainer-messenger-server project I don't have such a project? how do I point the deployment to a specific project?
You can set a project via gcloud config set my-project or providing the flag --project.
To see projects that you have access to, run gcloud projects list.

Changing target Firebase ID using firebase-tools CLI

At the command line...
When I run firebase deploy, I get the following error:
Error: The entered credentials were incorrect.
When I run firebase deploy --debug, I get the following (more detailed) error (and log) shown when you click here. (firebase-debug.log)
When I run firebase deploy --project good-project-id, I get the expected deployment behavior.
When I rerun firebase deploy and firebase deploy --debug I get the same errors already described.
How do I make the proper changes to eliminate the errors when running firebase deploy?
Notes:
I am running Mac OS/X Yosemite v10.10.5
I just ran the NPM installation procedure (via Homebrew) described here.
Look at the contents of your .firebaserc file in your project directory. You likely have a "default" project alias specified. Run firebase list and see if that project id shows up there as well (note it should be the project id, not the instance/subdomain name).
If it doesn't match, that's likely your issue. Another thing you can try is deleting the .firebaserc file and then running firebase use --add to create a new project alias.

Resources