我关注了this tutorial使用 firebase 和 Gitlab CI 部署我的网络项目。
我使用这个 conf 在 firebase 上部署:
# .gitlab-ci.yml
deploy:
stage: deploy
environment: production
before_script:
- npm i -g firebase-tools
script:
- firebase deploy --token "$FIREBASE_TOKEN" -P "$PROJECT_NAME" --debug
only:
refs:
- master
changes:
- src/**/*
我将 FIREBASE_TOKEN
变量存储在我的 GitLab 中作为protected
和masked
。
但是当它在管道中运行时失败并返回此错误消息:
$ firebase deploy --token "$FIREBASE_TOKEN" -P "$PROJECT_NAME" --debug
[2020-06-27T21:26:52.339Z] > 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"]
[2020-06-27T21:26:55.356Z] Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
at GoogleAuth.getApplicationDefaultAsync (/usr/local/lib/node_modules/firebase-tools/node_modules/google-auth-library/build/src/auth/googleauth.js:160:19)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at runNextTicks (internal/process/task_queues.js:66:3)
at listOnTimeout (internal/timers.js:518:9)
at processTimers (internal/timers.js:492:7)
at async GoogleAuth.getClient (/usr/local/lib/node_modules/firebase-tools/node_modules/google-auth-library/build/src/auth/googleauth.js:502:17)
at async GoogleAuth.getAccessToken (/usr/local/lib/node_modules/firebase-tools/node_modules/google-auth-library/build/src/auth/googleauth.js:524:24)
Error: Failed to authenticate, have you run firebase login?
ERROR: Job failed: exit code 1
我不知道为什么我得到:
Failed to authenticate, have you run firebase login?
因为我使用 token 通过 --token
标志进行身份验证。
有人知道为什么我会收到此错误吗?
最佳答案
好的,这是一个虚拟错误。我的变量 $FIREBASE_TOKEN
没有被考虑在内,因为我检查了 Protect variable (Export variable to pipelines running on protected branches and tags only.)
选项。但是我正在开发一个功能分支来测试它不 protected 。
关于firebase - Gitlab CI : Failed to authenticate, 你有运行 firebase 登录吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62615993/