Sub topic 11
Deploying and Reading Deployment Status
This chapter assumes you can already open an inbound change set in the target org and have validated it. You need the Deploy Change Sets permission in the target org. It covers how to deploy and how to read the status page afterward.
Starting a deployment
Open Setup, search for Inbound Change Sets, and click the change set name. Two buttons are available: Validate and Deploy. Deploy runs the same checks as validation, then saves the components to the org if the checks pass. A deployment is all or nothing. If any component or required test fails, Salesforce rolls back the whole change set.
If you validated recently, you can use Quick Deploy from the Deployment Status page. Quick Deploy skips the tests. It is available only for a validation that passed with the tests run in a production org, and only within 10 days of that validation.
- Open the inbound change set.
- Click Deploy.
- Confirm the prompt.
- Open Setup, search for Deployment Status, and watch the run.
The deployment lifecycle
A deployment moves through a small set of states.
A deployment waits in a queue when another one is running. It then runs the components and the tests. You can cancel a deployment while it is pending or in progress. A canceled or failed deployment leaves the target org unchanged.
Reading the Deployment Status page
The Deployment Status page lists in-progress and completed deployments. Each row has a status and a link to the details.
| Section | What it shows |
|---|---|
| Status | The overall state, such as In Progress, Succeeded, or Failed |
| Components deployed | A count of successes and failures, with the failed items listed |
| Test results | The number of tests run, failures, and the code coverage |
| Component failures | The component name, type, and the error message |
Start with the component failures. Each row names the component and the exact error. Then read the test failures, which give the class, method, and stack trace. Common errors include a missing dependency, a failed Apex test, and a field that already exists with a different type.
Check code coverage when you deploy Apex to production. Salesforce requires at least 75% overall coverage, and every trigger must have some coverage.
Confirming the result
After a successful deployment, confirm that the components are in the target org. For a custom object, open Object Manager. For a class, open Apex Classes. You can also retrieve the components with the CLI and compare them with the source sandbox.
sf project retrieve start --manifest manifest/package.xml --target-org MyProductionThis command uses the manifest from the earlier example. The target org alias is a placeholder, so replace it with your own alias. A successful retrieve confirms the named components exist in the target.
Exercise
A deployment of 12 components and 40 Apex tests to production shows 11 components succeeded and one test failed. What state is the target org in, and why?
Show answer
The target org is unchanged. A change set deployment is all or nothing, so one failed test makes Salesforce roll back every component. Fix the failing test or the code it covers, then validate and deploy again.
Exercise
Which section of the Deployment Status details do you read first to find the cause of a failed component, and what does it give you?
Show answer
Read the component failures section first. It lists each failed component with its type and the exact error message, such as a missing dependency.