platform-quick-deploy

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Quick Deploying to Prod

快速部署至生产组织

Promote a validated deploy to a Production org using the job ID from a prior
sf project deploy validate
. No tests re-run, no components re-validated — just the promotion.
使用之前
sf project deploy validate
生成的任务ID,将已验证的部署推广至Salesforce生产组织。无需重新运行测试,无需重新验证组件——仅执行推广操作。

Preconditions (gate strictly)

前置条件(严格执行)

Before doing ANYTHING, verify all four:
  1. Target is Production
    bash
    sf org display --target-org <alias> --json
    Confirm the target really is production. The reliable check is the gate's classifier (returns
    production|sandbox|scratch|trial|devhub|unknown
    ):
    bash
    sf org display --target-org <alias> --json | "${CLAUDE_PLUGIN_ROOT}/scripts/sf-deploy-gate" classify
    Production means
    isSandbox=false
    AND
    isScratch=false
    AND instance URL has no
    --
    (sandbox marker) AND no
    test.salesforce.com
    AND it is not a trial/Developer Edition host (
    orgfarm-*
    ,
    *.develop.my.salesforce.com
    ,
    *.pc-rnd.*
    , or a
    trialExpirationDate
    in the response — these report
    isSandbox
    /
    isScratch
    as
    null
    and must not be taken for production).
    If target is NOT production (classifier returns anything other than
    production
    ) → STOP and redirect to
    platform-metadata-deploy
    (which handles non-prod natively).
  2. A validation exists
    • Read
      .sfdx/last-validation.json
      if it exists (left there by
      platform-deploy-validate
      )
    • OR ask the user for the job ID
    • OR fall back to
      --use-most-recent
      (validates within last 3 days)
  3. Validation is fresh enough
    • Explicit
      --job-id
      : must be ≤10 days old per Salesforce's quick-deploy window
    • --use-most-recent
      : must be ≤3 days old
    • If the recorded
      createdAt
      exceeds the window → STOP and run
      platform-deploy-validate
      first
  4. 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"
在执行任何操作之前,需验证以下四项:
  1. 目标为生产组织
    bash
    sf org display --target-org <alias> --json
    确认目标确实是生产组织。可靠的检查方式是使用网关分类器(返回
    production|sandbox|scratch|trial|devhub|unknown
    ):
    bash
    sf org display --target-org <alias> --json | "${CLAUDE_PLUGIN_ROOT}/scripts/sf-deploy-gate" classify
    生产组织需满足:
    isSandbox=false
    isScratch=false
    ,且实例URL不含
    --
    (沙箱标记),且不是
    test.salesforce.com
    同时不是试用版/开发者版宿主(如
    orgfarm-*
    *.develop.my.salesforce.com
    *.pc-rnd.*
    ,或响应中包含
    trialExpirationDate
    ——这些组织的
    isSandbox
    /
    isScratch
    会返回
    null
    ,不能视为生产组织)。
    若目标非生产组织(分类器返回
    production
    以外的结果)→ 停止操作并引导至
    platform-metadata-deploy
    (原生支持非生产环境部署)。
  2. 存在已完成的验证
    • 若存在
      .sfdx/last-validation.json
      文件(由
      platform-deploy-validate
      生成),则读取该文件
    • 或向用户索要任务ID
    • 或退而使用
      --use-most-recent
      (仅对过去3天内的验证有效)
  3. 验证结果仍在有效期内
    • 明确指定
      --job-id
      :需符合Salesforce快速部署窗口要求,即≤10天
    • 使用
      --use-most-recent
      :需≤3天
    • 若记录的
      createdAt
      超出有效期→ 停止操作,先执行
      platform-deploy-validate
  4. 用户明确确认
    • 打印确认信息块(别名、实例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 --json
Or with
--use-most-recent
if the user opted in.
The 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
    sf project deploy start
    against a Production target (always validate then quick-deploy)
  • NEVER use
    --ignore-errors
    or
    --ignore-warnings
    on production
  • 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
    .sfdx/deploy-history/
    for the audit trail
  • If the prod-check hook denies the operation, do NOT bypass it — surface the denial to the user and recommend
    platform-deploy-validate
    first
  • 切勿针对生产组织执行
    sf project deploy start
    (必须先验证再快速部署)
  • 生产环境部署切勿使用
    --ignore-errors
    --ignore-warnings
    参数
  • 切勿自动确认——必须获得用户明确的“yes”答复
  • 切勿快速部署超出有效期的任务ID——需重新验证
  • 务必将部署报告持久化至
    .sfdx/deploy-history/
    ,用于审计追踪
  • 若生产检查钩子拒绝操作,切勿绕过——向用户展示拒绝信息,并建议先执行
    platform-deploy-validate