firebase.json postdeploy身份验证

时间:2018-05-30 20:18:46

标签: firebase firebase-authentication

我有以下firebase.json

{
  "functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint"
    ],
    "postdeploy": [
      "firebase list",
      "firebase database:set /config deploy/database/config.json -y"
    ],
    "ignore": [
      "**/node_modules/**"
    ],
    "source": "functions"
  },
  "database": {
    "rules": "database.rules.json"
  }
}

database.rules.json

{
  "rules": {
    "users": {
      "$uid": {
        ".read": "$uid === auth.uid",
        ".write": "$uid === auth.uid"
      }
    }
  }
}

但是,在CI上,postdeploy步骤失败:

Running command: firebase list
┌──────────────────────────────────────┬────────────────────────────┬─────────────┐
│ Name                                 │ Project ID / Instance      │ Permissions │
├──────────────────────────────────────┼────────────────────────────┼─────────────┤
│ My App Name (current)                │ my-app-name                │ Editor      │
└──────────────────────────────────────┴────────────────────────────┴─────────────┘

Running command: firebase database:set /config
deploy/database/config.json -y Error: An unexpected error has
occurred. Error: functions postdeploy error: Command terminated with
non-zero exit code2

Firebase命令显然以Editor运行。

我也可以在本地运行firebase database:set /config deploy/database/config.json -y

可能是什么问题?

1 个答案:

答案 0 :(得分:0)

事实证明"source": "functions"设置不适用于我的脚本的位置。我从

更改了脚本位置
firebase database:set /config deploy/database/config.json -y

firebase database:set /config functions/deploy/database/config.json -y

......现在它起作用了:

Running command: firebase database:set /config functions/deploy/database/config.json -y
✔  Data persisted successfully

总之,错误代码2firebase database:set命令无法找到JSON输入文件。