Sub topic 14
Checking, resuming, and canceling deployments
This chapter assumes you can run sf project deploy start against an authorized org, as covered earlier. It shows how to follow a deployment that is still running, pick it up again if your terminal stopped waiting, and stop it if you must.
A deployment runs in the org
When you run sf project deploy start, the CLI uploads your components and the org does the work. The CLI only watches. Each deployment gets a job ID, which starts with 0Af.
The command waits for a limited time, set by --wait in minutes. If the time runs out, or you press Ctrl+C, the CLI stops watching. The deployment keeps running in the org.
You can also skip watching on purpose. The --async flag returns right after the upload and prints the job ID.
sf project deploy start --manifest manifest/package.xml --target-org my-sandbox --wait 5
sf project deploy start --manifest manifest/package.xml --target-org my-sandbox --asyncDeployment states
Succeeded, Failed, and Canceled are final. A final deployment cannot be resumed or canceled.
Checking status with report
sf project deploy report asks the org for the current state of a deployment and prints it. It does not keep watching.
sf project deploy report --use-most-recent
sf project deploy report --job-id 0AfXXXXXXXXXXXXXXXReplace the placeholder with the ID printed by your deploy. --use-most-recent uses the last deployment you started from this project, so you do not need to copy the ID.
Resuming with resume
sf project deploy resume reconnects to a running deployment and waits for it to finish, as deploy start would have done.
sf project deploy resume --use-most-recentUse resume when you want to wait for the result. Use report when you only want a snapshot. Resume also lets the CLI finish its local work, such as updating source tracking, so prefer it after a deploy you started with --async and want to complete.
Canceling a deployment
To stop a deployment that is still running, use cancel.
sf project deploy cancel --use-most-recentCanceling is a request. The deployment moves to Canceling, then Canceled. If the org has already finished, the cancel has no effect. A canceled deployment saves no changes, because deployments are all or nothing.
Common mistakes
- Starting the same deployment again because the terminal timed out. Run
reportfirst. A second deploy may collide with the first. - Using
--use-most-recentafter switching projects or machines. The most recent ID is stored locally, so pass--job-idinstead. - Expecting
reportto wait. It returns at once, even for a running job.
Exercise
Your deploy printed "Deploy has been queued", and then your laptop lost its connection. You want to know the outcome and have the CLI finish its local updates. Which command do you run, and does the deployment need to be restarted?
Show answer
Run sf project deploy resume --use-most-recent (or pass --job-id). The deployment does not need a restart, because it runs in the org and continues without the CLI. Use sf project deploy report only if you want a status snapshot without waiting.