【问题标题】:Cloud Build Trigger - Not in Firebase app directory errorCloud Build Trigger - Not in Firebase app directory 错误
【发布时间】:2021-03-13 21:53:25
【问题描述】:

我在使用 Cloud Build Trigger 将 node.js (Angular) 应用程序从 Bitbucket 存储库部署到 Firebase 时遇到问题。 我执行了本文中的步骤 - https://cloud.google.com/build/docs/deploying-builds/deploy-firebase

  • 打开了必要的 API,
  • 服务帐号拥有所有必需的权限,
  • Firebase 社区构建器已部署并在 Container Registry 中可见,
  • Cloudbuild.json 文件被添加到存储库,
  • Cloud Build Trigger 已创建,它指向我的存储库的一个特定分支。

问题是在运行 Cloud Build Trigger 后,我收到以下错误:“错误:不在 Firebase 应用目录中(无法找到 firebase.json)”

出现这种错误的原因可能是什么?是否可以指向存储库中firebase应用程序和firebase.json文件的触发器?

编辑:
我的 cloudbuild.json 文件很简单:

{
  "steps": [
   {
      "name": "gcr.io/PROJECT_NAME/firebase",
      "args": [
         "deploy",
         "--project",
         "PROJECT_NAME",
         "--only",
         "functions"
       ]
  }
  ]
}

Cloud Build 触发器历史记录:

  starting build "build_id"

FETCHSOURCE
Initialized empty Git repository in /workspace/.git/
From https://source.developers.google.com/p/link
 * branch            branch_id -> FETCH_HEAD
HEAD is now at d8bc2f1 Add cloudbuild.json file
BUILD
Pulling image: gcr.io/PROJECT/firebase
Using default tag: latest
latest: Pulling PROJECT/firebase
1e987daa2432: Already exists
a0edb687a3da: Already exists
6891892cc2ec: Already exists
684eb726ddc5: Already exists
b0af097f0da6: Already exists
154aee36a7da: Already exists
37e5835696f7: Pulling fs layer
62eb6e670f1d: Pulling fs layer
47e62615d9f9: Pulling fs layer
428cea824ccd: Pulling fs layer
765a2c722bf9: Pulling fs layer
b3f5d0a285e3: Pulling fs layer
428cea824ccd: Waiting
765a2c722bf9: Waiting
b3f5d0a285e3: Waiting
47e62615d9f9: Verifying Checksum
47e62615d9f9: Download complete
62eb6e670f1d: Verifying Checksum
62eb6e670f1d: Download complete
765a2c722bf9: Verifying Checksum
765a2c722bf9: Download complete
b3f5d0a285e3: Verifying Checksum
b3f5d0a285e3: Download complete
37e5835696f7: Verifying Checksum
37e5835696f7: Download complete
428cea824ccd: Verifying Checksum
428cea824ccd: Download complete
37e5835696f7: Pull complete
62eb6e670f1d: Pull complete
47e62615d9f9: Pull complete
428cea824ccd: Pull complete
765a2c722bf9: Pull complete
b3f5d0a285e3: Pull complete
Digest: sha256:4b6b7214d6344c8247130bf3f5443a2851e39aed3ececb32dfb2cc25a5c07e44
Status: Downloaded newer image for gcr.io/PROJECT/firebase:latest
gcr.io/PROJECT/firebase:latest

Error: Not in a Firebase app directory (could not locate firebase.json)
ERROR
ERROR: build step 0 "gcr.io/PROJECT/firebase" failed: step exited with non-zero status: 1

Firebase.json 文件位于以下路径的存储库中:/apps/firebase/firebase.json 我看不到在 Cloud Build Trigger 配置中指向该路径的任何可能性。

【问题讨论】:

  • 你能分享你的 cloudbuild.json,至少是失败的部分吗?我可以帮你调试。此外,您是否尝试使用 CLI 运行 Cloud Build?来自哪个目录?
  • 我已经编辑了我的帖子。在推送 firebase 社区构建器时,我从 CLI 运行 Cloud Build。我是从“apps/firebase”路径完成的。在这种情况下,firebase 社区构建器的提交没有任何问题,并且它在我的 Container Registry 项目中可见。

标签: firebase google-cloud-platform continuous-deployment google-cloud-build


【解决方案1】:

我很确定您在运行命令时不在正确的目录中。要检查这一点,您可以添加此步骤

{
  "steps": [
   {
      "name": "gcr.io/cloud-builders/gcloud",
      "entrypoint":"ls"
      "args": ["-la"]
  }
  ]
}

如果您不在正确的目录中,并且需要在 ./app/firebase 中运行部署,您可以在步骤中添加此参数

{
  "steps": [
   {
      "name": "gcr.io/PROJECT_NAME/firebase",
      "dir": "app/firebase",
      "args": [
         "deploy",
         "--project",
         "PROJECT_NAME",
         "--only",
         "functions"
       ]
  }
  ]
}

让我知道它是否更好

【讨论】:

  • 添加 dir 参数有帮助。谢谢。但是现在我有另一个错误:`我正在部署函数运行命令:npm --prefix "$RESOURCE_DIR" run lint > lint > tslint --project tsconfig.json sh:1:tslint:未找到错误:函数预部署错误:命令终止非零退出代码127`我认为它与firebase,json文件中的预部署数组中的函数有关。你知道如何解决这个问题吗?
  • 我不是 Node 开发人员,所以我不知道。但是,您确定所有环境变量(此处为 RESOURCE_DIR)均已正确设置吗?
  • 通过在 cloudbuild.json 文件中添加 npm install 命令的第一步解决了问题。谢谢你的帮助。
猜你喜欢
  • 2020-07-03
  • 2020-06-18
  • 2016-01-01
  • 1970-01-01
  • 2017-08-27
  • 1970-01-01
  • 1970-01-01
  • 2021-01-13
  • 2020-04-07
相关资源
最近更新 更多