【问题标题】:deploy cloud functions using cloud build failed: Error: failed to get firebase project使用云构建部署云功能失败:错误:未能获取 Firebase 项目
【发布时间】:2022-09-12 11:00:43
【问题描述】:

=== 部署到\'project_id\'...

步骤1:

第 1 步:我部署功能

步骤1:

第 1 步:错误:无法获取 Firebase 项目 project_id。请确保该项目存在并且您的帐户有权访问它。

这是我尝试使用云构建部署云功能时遇到的错误。

这是我的cloudbuild.yaml 步骤:

#Install
- name: \'gcr.io/cloud-builders/npm\'
  args: [\'install\']
  
#Deploy
- name: \'gcr.io/flysample-75b81/firebase\'
  args: [\'deploy\']

这是我的 package.json

{
  \"name\": \"functions\",
  \"description\": \"Cloud Functions for Firebase\",
  \"scripts\": {
    \"serve\": \"firebase emulators:start --only functions\",
    \"shell\": \"firebase functions:shell\",
    \"start\": \"npm run shell\",
    \"deploy\": \"firebase deploy --only functions\",
    \"logs\": \"firebase functions:log\"
  },
  \"engines\": {
    \"node\": \"16\"
  },
  \"main\": \"index.js\",
  \"dependencies\": {
    \"body-parser\": \"^1.20.0\",
    \"firebase-admin\": \"^10.0.2\",
    \"firebase-functions\": \"^3.18.0\"
  },
  \"devDependencies\": {
    \"firebase-functions-test\": \"^0.2.0\"
  },
  \"private\": true
}

如果有人有想法,请告诉我如何解决此错误。

  • 你已经检查过这个documentation了吗?您在args 上缺少一些标志。让我知道它是否有帮助。
  • 请让我知道示例 cloudbuild 文件。因为我尝试了很多选择,但没有一个对我有用
  • @UjjwalKumar,f.e.你没有通过 <firebase-project-id>: args: [\'deploy\', \'--project=firebase-project-id\', \'--only=hosting\'] (来自上面的文档)

标签: node.js firebase google-cloud-functions google-cloud-build


【解决方案1】:

documentation 所述,

创建一个名为 cloudbuild.yaml 或 cloudbuild.json 的构建配置文件,其中 project-id 是您的 Cloud 项目 ID,而 firebase-project-id 是您的 Firebase 项目 ID

您应该在 .yaml.json 文件中指定您的 Firebase 项目 ID。请参阅下面的示例:

steps:
- name: gcr.io/project-id/firebase
  args: ['deploy', '--project=firebase-project-id', '--only=hosting']

【讨论】:

    猜你喜欢
    • 2023-04-01
    • 2021-12-01
    • 2020-10-19
    • 2018-08-05
    • 2022-09-01
    • 1970-01-01
    • 2019-01-30
    • 1970-01-01
    相关资源
    最近更新 更多