Firebase CI deploy no longer working
Version info
3.18.2
Platform Information
Linux (Using GitLab CI with a node:8.9-alpine image)
Steps to reproduce
The GitLab CI installs the latest version of Firebase CLI
npm install firebase-tools -g
The GitLab CI runs the deploy script in the correct directory.
cd dist/$CI_ENVIRONMENT_SLUG && firebase deploy --non-interactive --token $FIREBASE_KEY --project=$CI_ENVIRONMENT_SLUG
Expected behavior
I setup GitLab CI to build & deploy my project to Firebase a couple of months ago. It's been deploying every week successfully until the latest version (3.18.2). I haven't changed any of my setup. The last version that made the deploy successful (about two weeks ago) was version 3.17.7.
Update I tried forcing the CLI to use that version by changing the CI script to npm install @3.17.7. Even that didn't work. I suspect it could be an issue with the API server, not the CLI. Or maybe GitLab.
Actual behavior
The CLI responds with the following message: ⚠ Your CLI authentication needs to be updated to take advantage of new features. ⚠ Please run firebase login --reauth
Because I'm running this on CI, I am unable to use the above command. I have tried logging out of firebase on my local computer and creating new CI tokens.
Here is the full output of the error when run with --debug. I've removed the keys from the output.
[2018-04-12T21:06:25.408Z] ---------------------------------------------------------------------- [2018-04-12T21:06:25.412Z] Command: /usr/local/bin/node /usr/local/bin/firebase deploy --non-interactive --debug --project=staging [2018-04-12T21:06:25.412Z] CLI Version: 3.17.7 [2018-04-12T21:06:25.412Z] Platform: linux [2018-04-12T21:06:25.413Z] Node Version: v8.9.4 [2018-04-12T21:06:25.413Z] Time: Thu Apr 12 2018 21:06:25 GMT+0000 (UTC) [2018-04-12T21:06:25.413Z] ----------------------------------------------------------------------
[2018-04-12T21:06:25.427Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"] [2018-04-12T21:06:25.428Z] > attempting to authenticate via app default credentials [2018-04-12T21:06:25.668Z] ya29.c.El6......3Lbj [2018-04-12T21:06:25.669Z] > retrieved access token via default credentials [2018-04-12T21:06:25.671Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects/tapkeep-staging
Thu Apr 12 2018 21:06:25 GMT+0000 (UTC) [2018-04-12T21:06:25.875Z] <<< HTTP RESPONSE 404 server=nginx, date=Thu, 12 Apr 2018 21:06:25 GMT, content-type=application/json; charset=utf-8, content-length=87, connection=close, x-content-type-options=nosniff [2018-04-12T21:06:25.876Z] <<< HTTP RESPONSE BODY code=PROJECT_NOT_FOUND, message=The specified project was not found. [2018-04-12T21:06:25.878Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects
Thu Apr 12 2018 21:06:25 GMT+0000 (UTC) [2018-04-12T21:06:26.010Z] <<< HTTP RESPONSE 404 server=nginx, date=Thu, 12 Apr 2018 21:06:25 GMT, content-type=application/json; charset=utf-8, content-length=87, connection=close, x-content-type-options=nosniff [2018-04-12T21:06:26.010Z] <<< HTTP RESPONSE BODY code=PROJECT_NOT_FOUND, message=The specified project was not found.
⚠ Your CLI authentication needs to be updated to take advantage of new features. ⚠ Please run firebase login --reauth
[2018-04-12T21:06:26.012Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase"] [2018-04-12T21:06:26.013Z] > attempting to authenticate via app default credentials [2018-04-12T21:06:26.038Z] ya29.c.El6b......3Lbj [2018-04-12T21:06:26.039Z] > retrieved access token via default credentials [2018-04-12T21:06:26.039Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects/tapkeep-staging
Thu Apr 12 2018 21:06:26 GMT+0000 (UTC) [2018-04-12T21:06:26.180Z] <<< HTTP RESPONSE 404 server=nginx, date=Thu, 12 Apr 2018 21:06:26 GMT, content-type=application/json; charset=utf-8, content-length=87, connection=close, x-content-type-options=nosniff [2018-04-12T21:06:26.181Z] <<< HTTP RESPONSE BODY code=PROJECT_NOT_FOUND, message=The specified project was not found. [2018-04-12T21:06:26.182Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects
Thu Apr 12 2018 21:06:26 GMT+0000 (UTC) [2018-04-12T21:06:26.312Z] <<< HTTP RESPONSE 404 server=nginx, date=Thu, 12 Apr 2018 21:06:26 GMT, content-type=application/json; charset=utf-8, content-length=87, connection=close, x-content-type-options=nosniff [2018-04-12T21:06:26.313Z] <<< HTTP RESPONSE BODY code=PROJECT_NOT_FOUND, message=The specified project was not found.
Error: HTTP Error: 404, The specified project was not found. [2018-04-12T21:06:26.316Z] Error Context: { "body": { "error": { "code": "PROJECT_NOT_FOUND", "message": "The specified project was not found." } }, "response": { "statusCode": 404, "body": { "error": { "code": "PROJECT_NOT_FOUND", "message": "The specified project was not found." } }, "headers": { "server": "nginx", "date": "Thu, 12 Apr 2018 21:06:26 GMT", "content-type": "application/json; charset=utf-8", "content-length": "87", "connection": "close", "x-content-type-options": "nosniff" }, "request": { "uri": { "protocol": "https:", "slashes": true, "auth": null, "host": "admin.firebase.com", "port": 443, "hostname": "admin.firebase.com", "hash": null, "search": null, "query": null, "pathname": "/v1/projects", "path": "/v1/projects", "href": "https://admin.firebase.com/v1/projects" }, "method": "GET" } } }
I have two projects/environments: one works (alpha) but the other (beta) encounters this issue. I'm on GitLab too, but I don't think the issue is on their end since one of the projects succeeds in deploying.
Having similar issues with a different debug output - @brianschwabauer were you able to get it working?
Documented my experiences here - https://github.com/firebase/firebase-tools/issues/342#issuecomment-388044710
@mmorrison24 No, I haven't found a solution yet. I've tried just about everything I can think of and have lost a couple of days of work trying to figure it out. So now I just deploy from my local computer instead of GitLab CI. I'm thinking about using a different cloud provider if there's no solution.
Some things I've tried:
- generating a new CI token. Logging out of the old one.
- 30+ combinations of the deploy script - like including the 'firebase use
' or just using '-P ' - installing firebase-tools globally in the CI
- installing firebase-tools locally in the CI
- installing the last 4 versions of firebase-tools
Nothing seems to work. I actually think it probably has something to do with the backend of Firebase and not the firebase-tools library itself.
This has been fixed for me as of version 3.18.5. I didn't change anything on my end. So either 3.18.5 fixed it or Gitlab did something on their end.
I get the same problem with 3.18.5, need to reopen this issue as it's not solved.
https://travis-ci.com/firstorder-gmbh/universal-starter/builds/75181032

I also get: Authentication Error: Your credentials are no longer valid. Please run firebase login --reauth
Tried also to generate new tokens, checked for escaping chars problems, nothing worked.
I was also experiencing this issue, I ran firebase login:ci to generate a token.
Updated my deploy step to be (adding FIREBASE_TOKEN to my CI/CD variables within my project):
"deploy": "firebase deploy --token $FIREBASE_TOKEN",
After doing this I was able to deploy successfully.
Sample gitlab-ci:
- npm install
- npm run build
- npm run deploy
Having the very same issue as @brianschwabauer reported originally.
- firebase-tools: v4.2.0
- firebase: v5.4.1

Using the exact same commands my GitLab CI executes, it works. Any idea? locally I'm obviously authenticated, the CI uses the token
Update
Turns out, my issue was that I activated the "protected" flag on the GitLab CI variables for my Firebase token. Not sure why I didn't get an authentication failure, but rather some strange (either) 404 or "no active project" error. But once I deactivated the protected flag (which didn't mean what I meant it was for), it worked

@juristr thanks for the update. I had exactly the same problem. Works like a charm!!
Same for me, just switching off the protected radio fixed the 404 issue. Thanks a lot!
Found this in the docs 😊
Protected variables
Notes: This feature requires GitLab 9.3 or higher.
Variables could be protected. Whenever a variable is protected, it would only be securely passed to pipelines running on the protected branches or protected tags. The other pipelines would not get any protected variables. Protected variables can be added by going to your project's Settings > CI/CD, then finding the section called Variables, and check "Protected". Once you set them, they will be available for all subsequent pipelines.
https://gitlab.com/help/ci/variables/README#protected-variables
Closing as part of cleanup. This doesn't seem related to firebase-tools codebase, but there are good workarounds in the discussion by @juristr
Firebase deploy works, but in case of CI (e.g. GitLab CI) you need to explicitly execute the predeploy script. Had exactly the same case.