Sub topic 7
When Quick Deploy Is Available
This chapter assumes you can run sf project deploy validate and read its output, and that you know the test levels and the 75% coverage rule from earlier chapters. Here you learn the conditions that make a validation eligible for quick deploy. Knowing them lets you check eligibility before the release window, not during it.
What quick deploy needs from a validation
Quick deploy promotes a validation that already passed. It reuses the test results from that validation, so Salesforce does not run the Apex tests a second time. That is only safe when the earlier run proved what production requires. Several conditions follow from that.
| Condition | Why it matters |
|---|---|
| The validation succeeded | A failed validation never produced a deployable result. |
| The target is a production org | Quick deploy exists to shorten production deployments, where tests are mandatory. |
| Tests actually ran | A validation with `NoTestRun` has no test results to reuse. |
| Coverage requirements were met | The saved results must satisfy the production coverage gate. |
| The validation is recent | Salesforce keeps validation results for a limited time, currently 10 days. |
The sections below take these conditions one at a time.
The test level must produce test results
Use RunLocalTests, RunAllTestsInOrg, or RunSpecifiedTests for the validation. The NoTestRun level does not qualify, and neither does a validation that skipped tests for any other reason.
RunSpecifiedTests has a stricter coverage rule. Each Apex class and trigger in the deployment must have at least 75% coverage from the tests you named. With RunLocalTests, the 75% threshold applies to the org's overall coverage. This is a common reason a specified-tests validation passes the tests but still cannot be quick deployed.
The 10-day window
A validation stays eligible for 10 days after it completes. After that, the job ID still exists and sf project deploy report still shows it. Quick deploy will refuse it, and you must validate again.
Plan for this when a release slips. A validation run on a Monday for a release scheduled 12 days later is useless for quick deploy.
Changes after the validation
Quick deploy replays the validated package. It does not let you change the contents. If you edit a class, add a component, or change the manifest, you need a new validation and a new job ID.
The org can also change under you. If another deployment lands in production after your validation, such as a hotfix or a second team's release, your results may no longer describe the current org. The quick deploy can then fail or be unavailable. After any other production deployment, check the status of your validation again.
Checking eligibility from the CLI
Run the report command with the job ID from your validation:
sf project deploy report --job-id 0AfXXXXXXXXXXXXXXX --target-org prodLook for these signs in the output:
- The status is
Succeeded, notFailedorCanceled. - The test counts show tests that ran, with no failures.
- The completion date is within the last 10 days.
If the validation looks good, the quick deploy command is the one from the spine:
sf project deploy quick \
--job-id 0AfXXXXXXXXXXXXXXX \
--target-org prodThe next chapter walks through running it. If the command rejects the job ID, return to the decision flow above and check each condition.
Habits that keep a validation eligible
- Record the job ID and the completion date when the validation finishes.
- Validate with the same test level you would use for the real deployment, and never
NoTestRun. - Freeze the package contents after validating. Any edit means a new validation.
- Ask other teams about production deployments scheduled between your validation and your release window.
- Validate close enough to the release that the 10-day window cannot expire.
Exercise
A teammate validated a package against production with RunSpecifiedTests, naming one test class. The tests all passed, but quick deploy is rejected. Name two possible causes.
Show answer
Possible causes: (1) With RunSpecifiedTests, every class and trigger in the package needs at least 75% coverage from the named tests, and the one test class may not cover them all. (2) The validation may be older than 10 days, or another deployment may have changed production after the validation. Either one makes the validation ineligible, and the fix is to revalidate.