firebase - Gitlab CI : Failed to authenticate, 你有运行 firebase 登录吗?

标签 firebase gitlab gitlab-ci firebase-cli

我关注了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 中作为protectedmasked

但是当它在管道中运行时失败并返回此错误消息:

$ 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/

相关文章:

git - git 提供程序错误中不支持的 URL 协议(protocol)

ios - 上传到 Firebase 时元数据出现异常 - ios - Objective c

ios - 当应用程序处于后台时,推送通知不起作用

Flutter 分析发现 Gitlab CI/CD 管道中存在本地未发现的问题

docker - gitlab CI 作业使用哪个 shell?

gitlab-ci - 有没有比注释掉所有内容更好的方法来禁用/跳过 GitLab CI 管道中的作业?

gitlab - 如何设置 gitlab CI runners?

java - 将 Firebase json 转换为 Java 对象

Typescript 和 Firebase 9

Gitlab api 在合并请求中获取提交