platform-quick-deploy
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseQuick Deploying to Prod
快速部署至生产组织
Promote a validated deploy to a Production org using the job ID from a prior . No tests re-run, no components re-validated — just the promotion.
sf project deploy validate使用之前生成的任务ID,将已验证的部署推广至Salesforce生产组织。无需重新运行测试,无需重新验证组件——仅执行推广操作。
sf project deploy validatePreconditions (gate strictly)
前置条件(严格执行)
Before doing ANYTHING, verify all four:
-
Target is Productionbash
sf org display --target-org <alias> --jsonConfirm the target really is production. The reliable check is the gate's classifier (returns):production|sandbox|scratch|trial|devhub|unknownbashsf org display --target-org <alias> --json | "${CLAUDE_PLUGIN_ROOT}/scripts/sf-deploy-gate" classifyProduction meansANDisSandbox=falseAND instance URL has noisScratch=false(sandbox marker) AND no--AND it is not a trial/Developer Edition host (test.salesforce.com,orgfarm-*,*.develop.my.salesforce.com, or a*.pc-rnd.*in the response — these reporttrialExpirationDate/isSandboxasisScratchand must not be taken for production).nullIf target is NOT production (classifier returns anything other than) → STOP and redirect toproduction(which handles non-prod natively).platform-metadata-deploy -
A validation exists
- Read if it exists (left there by
.sfdx/last-validation.json)platform-deploy-validate - OR ask the user for the job ID
- OR fall back to (validates within last 3 days)
--use-most-recent
- Read
-
Validation is fresh enough
- Explicit : must be ≤10 days old per Salesforce's quick-deploy window
--job-id - : must be ≤3 days old
--use-most-recent - If the recorded exceeds the window → STOP and run
createdAtfirstplatform-deploy-validate
- Explicit
-
Explicit user confirmation
- Print a confirmation block (alias, instance URL, edition, validated component count, test results) and ask: "Confirm deploy to PRODUCTION? (yes/no)"
- Do NOT proceed without an explicit "yes"
在执行任何操作之前,需验证以下四项:
-
目标为生产组织bash
sf org display --target-org <alias> --json确认目标确实是生产组织。可靠的检查方式是使用网关分类器(返回):production|sandbox|scratch|trial|devhub|unknownbashsf org display --target-org <alias> --json | "${CLAUDE_PLUGIN_ROOT}/scripts/sf-deploy-gate" classify生产组织需满足:且isSandbox=false,且实例URL不含isScratch=false(沙箱标记),且不是--,同时不是试用版/开发者版宿主(如test.salesforce.com、orgfarm-*、*.develop.my.salesforce.com,或响应中包含*.pc-rnd.*——这些组织的trialExpirationDate/isSandbox会返回isScratch,不能视为生产组织)。null若目标非生产组织(分类器返回以外的结果)→ 停止操作并引导至production(原生支持非生产环境部署)。platform-metadata-deploy -
存在已完成的验证
- 若存在文件(由
.sfdx/last-validation.json生成),则读取该文件platform-deploy-validate - 或向用户索要任务ID
- 或退而使用(仅对过去3天内的验证有效)
--use-most-recent
- 若存在
-
验证结果仍在有效期内
- 明确指定:需符合Salesforce快速部署窗口要求,即≤10天
--job-id - 使用:需≤3天
--use-most-recent - 若记录的超出有效期→ 停止操作,先执行
createdAtplatform-deploy-validate
- 明确指定
-
用户明确确认
- 打印确认信息块(别名、实例URL、版本、已验证组件数量、测试结果),并询问:“确认部署至生产组织?(yes/no)”
- 未收到明确的“yes”答复,不得继续执行
Workflow
工作流程
Step 1 — Display the production confirmation banner
步骤1 — 显示生产部署确认横幅
Format exactly:
┌─ PRODUCTION DEPLOY ─────────────────────────────┐
│ Org alias: <alias> │
│ Instance: <instanceUrl> │
│ Edition: <edition> │
│ Validation ID: <jobId> │
│ Validated: <createdAt> (X days ago) │
│ Components: <componentCount> queued │
│ Tests: <run>/<passed>/<failed> │
└─────────────────────────────────────────────────┘
Confirm deploy to PRODUCTION? (yes/no)严格按照以下格式显示:
┌─ 生产组织部署 ─────────────────────────────┐
│ 组织别名: <alias> │
│ 实例地址: <instanceUrl> │
│ 版本: <edition> │
│ 验证ID: <jobId> │
│ 验证时间: <createdAt> (X天前) │
│ 组件数量: <componentCount> 已排队 │
│ 测试结果: <run>/<passed>/<failed> │
└─────────────────────────────────────────────────┘
确认部署至生产组织?(yes/no)Step 2 — Run the quick deploy
步骤2 — 执行快速部署
After "yes":
bash
sf project deploy quick --job-id <id> --target-org <alias> --wait 30 --jsonOr with if the user opted in.
--use-most-recentThe quick deploy will:
- Promote the validated components to the org
- NOT re-run tests (per Salesforce platform behavior)
- Return final deploy status
收到“yes”答复后执行:
bash
sf project deploy quick --job-id <id> --target-org <alias> --wait 30 --json若用户选择使用,则使用该参数。
--use-most-recent快速部署将:
- 将已验证的组件推广至目标组织
- 不会重新运行测试(符合Salesforce平台行为)
- 返回最终部署状态
Step 3 — Capture the deploy report
步骤3 — 捕获部署报告
After completion, persist for audit:
bash
mkdir -p .sfdx/deploy-history
sf project deploy report --job-id <id> --target-org <alias> --json > ".sfdx/deploy-history/<id>.json"Surface to the user:
- ✅ Deploy succeeded — components deployed, time taken
- ⚠️ Deploy failed — error summary; recommend looking at the report
部署完成后,将报告持久化用于审计:
bash
mkdir -p .sfdx/deploy-history
sf project deploy report --job-id <id> --target-org <alias> --json > ".sfdx/deploy-history/<id>.json"向用户展示结果:
- ✅ 部署成功——已部署组件、耗时
- ⚠️ 部署失败——错误摘要;建议查看部署报告
Step 4 — Post-deploy guidance
步骤4 — 部署后指引
After a successful prod deploy, suggest:
- Smoke-test critical paths in the org (provide direct URLs if known)
- Monitor the prod environment for the next 30 min
- Check Setup → Deployment Status to confirm
- If anything regressed: prepare a rollback plan (re-deploy the previous version's package)
生产部署成功后,建议:
- 在组织中对关键路径进行冒烟测试(若已知,提供直接URL)
- 在接下来30分钟内监控生产环境
- 检查Setup → Deployment Status确认状态
- 若出现回退情况:准备回滚计划(重新部署上一版本的包)
Rules
规则
- NEVER run against a Production target (always validate then quick-deploy)
sf project deploy start - NEVER use or
--ignore-errorson production--ignore-warnings - NEVER auto-confirm — require an explicit "yes" from the user
- NEVER quick-deploy a job ID older than its validity window — re-validate instead
- ALWAYS persist the deploy report to for the audit trail
.sfdx/deploy-history/ - If the prod-check hook denies the operation, do NOT bypass it — surface the denial to the user and recommend first
platform-deploy-validate
- 切勿针对生产组织执行(必须先验证再快速部署)
sf project deploy start - 生产环境部署切勿使用或
--ignore-errors参数--ignore-warnings - 切勿自动确认——必须获得用户明确的“yes”答复
- 切勿快速部署超出有效期的任务ID——需重新验证
- 务必将部署报告持久化至,用于审计追踪
.sfdx/deploy-history/ - 若生产检查钩子拒绝操作,切勿绕过——向用户展示拒绝信息,并建议先执行
platform-deploy-validate