Sub topic 5
Validating first and using quick deploy
This chapter assumes you can run sf project deploy start against a production org, you know what a package.xml manifest is, and you know that Apex tests run during production deployments. It covers how a validation run lowers the chance that you need a rollback, and how quick deploy shortens the release window.
Why validation belongs in a rollback plan
The best rollback is one you never perform. A validation runs the same checks as a real deployment: metadata compiles, dependencies resolve, and tests pass with enough code coverage. It then discards the result instead of saving it. Production is never changed.
Validation catches the failures you read about in the earlier chapters on failure reports. Those failures include missing dependencies, broken tests, and coverage below the required level. You find them before the release window, when nothing needs undoing.
Running a validation
Validate with the same manifest and test level you plan to use for the release:
sf project deploy validate --manifest manifest/package.xml --target-org prod --test-level RunLocalTestsThe command prints a job ID that starts with 0Af. Keep it. You need it to check results and to run a quick deploy later.
Check the outcome at any time:
sf project deploy report --job-id 0AfXXXXXXXXXXXXXXX --target-org prodIf the report shows component or test failures, fix them in source control and validate again. Each new validation produces a new job ID, and only a successful one can be quick deployed.
Quick deploy
A quick deploy takes a successful validation and saves its changes to the org without running the tests again. Tests are usually the slowest part of a production deployment, so the release window shrinks to the time needed to write the metadata.
sf project deploy quick --job-id 0AfXXXXXXXXXXXXXXX --target-org prodYou can follow it with the same deploy report command, using the job ID that the quick deploy prints.
Conditions for a quick deploy
A quick deploy is only accepted when the validation meets these conditions:
- The validation succeeded and ran tests. In practice that means
RunLocalTests,RunAllTestsInOrg, orRunSpecifiedTests. A validation withNoTestRuncannot be quick deployed. - The validation finished no more than 10 days ago.
- Code coverage requirements were met during the validation.
If the target org changes between validation and quick deploy, for example another team deploys the same components, Salesforce can reject the quick deploy. Validate again if that happens. Do not assume the old result still applies.
Where this fits with backups
Take your baseline before you validate, so the backup reflects production as it stands today:
sf project retrieve start --manifest manifest/package.xml --target-org prod --output-dir backup/pre-releaseA sensible order for a release is:
- Retrieve the backup and tag the Git baseline.
- Validate and fix until it passes.
- Wait for the agreed release window.
- Quick deploy with the saved job ID.
- Smoke test, and start your rollback runbook if the release misbehaves.
Common errors
| Symptom | Likely cause | What to do |
|---|---|---|
| Quick deploy is rejected as expired | The validation is older than 10 days | Validate again |
| Quick deploy says no valid validation exists | The validation ran with `NoTestRun`, or it failed | Validate with a test level that runs tests |
| Quick deploy fails on a component | Production changed after the validation | Validate again against the current org state |
| Wrong job ID | You used the ID from a failed attempt | Look up the ID of the last successful validation |
Exercise
Your team validated a release on Monday with RunLocalTests and it passed. The next Wednesday, 9 days later, you run a quick deploy and it succeeds without running tests. The release then causes a bug in production. Did the validation fail to protect you, and what should you do first?
Show answer
The validation did its job: it confirmed the metadata deployed and tests passed, and the quick deploy was inside the 10-day window. It does not check business behavior, so a bug can still reach production. Use the pre-release backup and the Git baseline to roll back by redeploying the previous version, as described in the next chapters. Starting from the saved job ID and the pre-release backup, you can also report on the quick deploy with sf project deploy report to confirm what was changed.