我有以下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
。
可能是什么问题?
答案 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
总之,错误代码2
是firebase database:set
命令无法找到JSON输入文件。