zeabur-variables
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseZeabur Variables Management
Zeabur 变量管理
Always useto invoke Zeabur CLI. Never usenpx zeabur@latestdirectly or any other installation method. Ifzeaburis not available, install Node.js first.npxDo not guess CLI syntax. Only,create,update,delete, andenvare valid subcommands. Subcommands likelistorsetdo not exist and will silently fail with no error output.add
请始终使用调用Zeabur CLI。 切勿直接使用npx zeabur@latest或其他任何安装方式。如果没有zeabur,请先安装Node.js。npx不要猜测CLI语法。 只有、create、update、delete和env是有效的子命令。list或set这类子命令不存在,会无错误输出地静默失败。add
Known Issues
已知问题
- Use not
--id— name lookup is unreliable--name - gets empty — shell expands before CLI receives; use single quotes
${VAR} - replaces ALL variables — it overwrites the entire variable set with the .env file contents; existing variables not in the file will be removed
variable env
- 使用而非
--id—— 通过名称查找不可靠--name - 变为空值 —— 外壳会在CLI接收前展开变量;请使用单引号
${VAR} - 会替换所有变量 —— 它会用.env文件的内容覆盖整个变量集合;文件中不存在的现有变量将被删除
variable env
Create Variables
创建变量
Creates new variables. Errors if a key already exists — use to change existing keys.
updatebash
undefined创建新变量。如果键已存在则报错 —— 请使用修改现有键。
updatebash
undefinedAlways use service ID — use the zeabur-service-list
skill to get it
zeabur-service-list请始终使用服务ID —— 使用zeabur-service-list
技能获取
zeabur-service-listnpx zeabur@latest variable create --id <service-id>
-k "KEY1=value1"
-k "KEY2=value2"
-y -i=false
-k "KEY1=value1"
-k "KEY2=value2"
-y -i=false
undefinednpx zeabur@latest variable create --id <service-id>
-k "KEY1=value1"
-k "KEY2=value2"
-y -i=false
-k "KEY1=value1"
-k "KEY2=value2"
-y -i=false
undefinedUpdate Variables
更新变量
Updates only the specified keys. Does NOT clear other variables.
bash
npx zeabur@latest variable update --id <service-id> \
-k "KEY1=new_value1" \
-k "KEY2=new_value2" \
-y -i=false仅更新指定的键。不会清除其他变量。
bash
npx zeabur@latest variable update --id <service-id> \
-k "KEY1=new_value1" \
-k "KEY2=new_value2" \
-y -i=falseDelete Variables
删除变量
Deletes only the specified keys.
bash
npx zeabur@latest variable delete --id <service-id> \
--delete-keys "KEY1" \
--delete-keys "KEY2" \
-y -i=false仅删除指定的键。
bash
npx zeabur@latest variable delete --id <service-id> \
--delete-keys "KEY1" \
--delete-keys "KEY2" \
-y -i=falseList Variables
列出变量
bash
npx zeabur@latest variable list --id <service-id> -i=falsebash
npx zeabur@latest variable list --id <service-id> -i=falseLoad from .env File
从.env文件加载
Warning: This replaces ALL variables on the service with the contents of the .env file. Existing variables not in the file will be removed.
bash
npx zeabur@latest variable env --id <service-id> -f .envAfter running , you must restart the service manually to apply changes.
env警告: 此操作会用.env文件的内容替换服务上的所有变量。文件中不存在的现有变量将被删除。
bash
npx zeabur@latest variable env --id <service-id> -f .env运行命令后,必须手动重启服务才能使更改生效。
envVariable References
变量引用
Warning: The CLIflag uses Cobra's-kparser which cannot reliably handle values containingStringToStringVar, even with single quotes. The value may be truncated or emptied. See zeabur/cli#201.${}
bash
undefinedbash
undefinedWRONG — shell expands ${VAR} to empty
错误示例 —— 外壳会将${VAR}展开为空值
npx zeabur@latest variable create --id <service-id> -k "REDIS_URL=${REDIS_URI_INTERNAL}" -y -i=false
npx zeabur@latest variable create --id <service-id> -k "REDIS_URL=${REDIS_URI_INTERNAL}" -y -i=false
STILL UNRELIABLE — single quotes prevent shell expansion but Cobra's CSV parser may still mangle the value
仍不可靠 —— 单引号可防止外壳展开,但Cobra的CSV解析器仍可能损坏值
npx zeabur@latest variable create --id <service-id> -k 'REDIS_URL=${REDIS_URI_INTERNAL}' -y -i=false
npx zeabur@latest variable create --id <service-id> -k 'REDIS_URL=${REDIS_URI_INTERNAL}' -y -i=false
RECOMMENDED — set variable references in Zeabur Dashboard
推荐方式 —— 在Zeabur控制台中设置变量引用
Or use GraphQL API with updateEnvironmentVariable(data: Map!) mutation
或使用带有updateEnvironmentVariable(data: Map!) mutation的GraphQL API
For cross-service variable references like `${POSTGRES_CONNECTION_STRING}` (Zeabur uses a flat namespace — all exposed variables from other services are merged directly, no service prefix needed), **always use the Zeabur Dashboard** until the CLI bug is fixed.
对于跨服务变量引用,例如`${POSTGRES_CONNECTION_STRING}`(Zeabur使用扁平命名空间——所有来自其他服务的暴露变量会直接合并,无需服务前缀),**请始终使用Zeabur控制台**,直到CLI的bug修复。Quick Reference
快速参考
| Need | Command | Behavior |
|---|---|---|
| Add new vars | | Errors if key exists |
| Change existing vars | | Only updates specified keys |
| Remove specific vars | | Only removes specified keys |
| Overwrite all vars from file | | Replaces entire variable set |
| View vars | | Read-only |
| 需求 | 命令 | 行为 |
|---|---|---|
| 添加新变量 | | 若键已存在则报错 |
| 修改现有变量 | | 仅更新指定的键 |
| 删除特定变量 | | 仅删除指定的键 |
| 从文件覆盖所有变量 | | 替换整个变量集合 |
| 查看变量 | | 只读 |