Sub topic 12
Planning validation around a release window
This chapter assumes you can run sf project deploy validate, read a deployment report, and know the quick deploy eligibility rules from earlier chapters. Here you will turn those pieces into a schedule.
Why split the release in two
A production deployment with RunLocalTests can take from minutes to hours, depending on how many tests your org has. During that time the release window is open and the team waits. Validation moves that wait out of the window. You run the slow part days earlier and keep only the fast part, the quick deploy, for the window itself.
| Phase | When | What runs | Changes production? |
|---|---|---|---|
| Validation | Days before the window | Metadata checks and Apex tests | No |
| Go/no-go check | Start of the window | A status report on the validation | No |
| Quick deploy | Inside the window | Saves the validated components | Yes |
Build the timeline backward
Start from the window and work backward. The validation must complete no more than 10 days before the quick deploy, so schedule it well inside that limit. Most teams validate one to three days ahead. That leaves time to fix failures and re-validate, and it keeps the validation from expiring.
Freeze the content first
A validation only covers the exact components you validated. If someone adds a class to the release afterward, that class was never validated, so you need a new validation. Agree on a content freeze before you validate. After the freeze, merge only fixes that you also re-validate.
Changes in production matter too. If an admin edits metadata that your components depend on, or another deployment lands first, your validated job may no longer be eligible. Ask other teams not to deploy to production between your validation and your window.
Capture the job ID in a script
A job ID that lives only in a terminal scrollback is easy to lose. Save it where the release manager can find it. This script runs the validation and writes the ID to a file.
#!/usr/bin/env bash
set -euo pipefail
sf project deploy validate \
--manifest manifest/package.xml \
--test-level RunLocalTests \
--target-org prod \
--json > validation-result.json
jq -r '.result.id' validation-result.json > validated-job-id.txt
echo "Validated job ID: $(cat validated-job-id.txt)"Commit the ID to your release ticket as well, along with the date and time the validation completed. That timestamp lets anyone check the 10-day limit at a glance.
Run a go/no-go check at the start of the window
Before you deploy, confirm the validation is still good. A report is cheap and changes nothing.
sf project deploy report \
--job-id "$(cat validated-job-id.txt)" \
--target-org prodLook for a status of Succeeded and a test summary with no failures. If the status is anything else, or if production changed since the validation, treat it as a no-go for quick deploy. Re-validate and decide whether the window can absorb the full test run.
Deploy inside the window
When the check passes, run the quick deploy.
sf project deploy quick \
--job-id "$(cat validated-job-id.txt)" \
--target-org prodBecause the tests are not repeated, this usually finishes in a fraction of the original validation time. Then run your smoke tests and close the ticket.
Plan for failure
Decide the fallback before the window opens. A short list helps.
- If validation fails days ahead, you have time to fix and re-validate. This is the main benefit of the approach.
- If quick deploy is unavailable in the window, choose between running a full deployment with tests, which takes longer, or postponing. Decide the cutoff time in advance.
- If the quick deploy itself fails, read the report for the cause. Do not retry blindly.
Exercise
Your release window is Saturday at 02:00. Content freezes Thursday morning. Name a sensible time to run the validation, and say what you check at the start of the window.
Show answer
Validate Thursday after the freeze, or Friday, so there is time to fix failures and re-validate, and so the 10-day limit is not a concern. At the start of the window, run sf project deploy report with the saved job ID to confirm the status is Succeeded with no test failures and that production has not changed. If so, run sf project deploy quick. If not, re-validate and follow your fallback plan.