Sub topic 11
Promoting work items to production
This chapter assumes you can read a Git branch history, and you know the pipeline, stage and work item terms from earlier chapters. It also assumes you have already committed a change and merged its pull request into the first stage's branch. Here you follow that change through the remaining stages to production.
What promotion does
Promotion moves the changes of one or more work items from one pipeline stage to the next. DevOps Center does two things in one action:
- It merges the source stage's branch into the next stage's branch in Git.
- It deploys the merged metadata to the environment attached to the next stage.
Promotion is not a copy of the org's current state. The deployment contains the metadata recorded in the work item's commits, so what reaches production is what was reviewed in the pull request.
A promotion is also the point where the stage's test settings apply. A stage that sets a test level runs those tests during the deployment. If the deployment fails, the stage's branch and environment stay unchanged, and the work item stays where it was.
The promotion path
A typical pipeline has a development stage, an integration stage, UAT and production. Each stage maps to one branch and one org.
The first hop is the pull request covered in the previous chapter. Every later hop is a promotion from the Pipeline view.
Promoting step by step
- Open the project and go to the Pipeline view.
- In the stage that holds the work item, select the work items to promote.
- Click Promote. The label can read "Promote Selected" in some releases.
- DevOps Center validates the combined change. It checks for conflicts with the target branch and, if the stage requires it, runs the stage's tests.
- Confirm the promotion. The merge and deployment start, and progress appears on the work item.
- When the deployment succeeds, the work items move to the next stage column.
You can promote several work items at once. They merge and deploy together as one unit, so a failure in one blocks all of them. Smaller batches make failures easier to diagnose, while larger batches cost fewer deployment windows.
Previewing a promotion
Before you click Promote, check what would travel. Each stage branch is an ordinary Git branch, so you can compare them. This command lists the commits that have reached UAT but not yet main:
git fetch origin
git log --oneline origin/main..origin/UATEvery commit in that list is carried by the next promotion. If you see a commit that belongs to a work item you did not expect, stop and find out why it is in UAT before you promote.
Validating outside DevOps Center
You can also run a validation-only deployment with the Salesforce CLI. A validation checks the deployment and runs tests, but it does not change the org.
sf org login web --alias uat
sf project deploy start --source-dir force-app --target-org uat --dry-run --test-level RunLocalTestsThis is useful when a promotion in DevOps Center fails and you want faster feedback on the error. The CLI call deploys whatever is in your local force-app folder, so check out the right branch first. A passing CLI validation does not guarantee a passing promotion, because the promotion deploys the merged stage branch.
Promotion to production
The last stage differs from the others in three ways:
- Tests are mandatory. Production deployments that include Apex run local tests by default. A stage can set a stricter test level, but it cannot skip tests that Salesforce requires.
- The merge reaches
main. The production stage's branch is usuallymain, so a successful promotion makesmainmatch what is live. - Mistakes cost more. Users see the result, and undoing a metadata deployment is not automatic.
For these reasons, many teams restrict who can promote into production and schedule the promotion for a low-traffic window. Roles and governance are covered in a later chapter.
Common failures
| Symptom | Likely cause | What to do |
|---|---|---|
| Promotion stops with a merge conflict | Another work item changed the same component in the target branch | Resolve the conflict as described in the conflicts chapter, then retry |
| Deployment fails on a missing component | A dependency lives in a work item that has not been promoted | Promote the work item that holds the dependency, or add it to the same promotion |
| Test failure only in the target org | The target org's data or configuration differs from the sandbox | Fix the test or the data setup, commit to the work item, and promote again |
| Work item stays in the old stage | The deployment failed and rolled back | Read the deployment error on the work item, then correct and retry |
| Unexpected files in the deployment | Tooling files were committed | Add them to `.forceignore` and remove them from the branch |
A .forceignore file keeps local tooling files out of the deployment, so only real metadata moves:
# .forceignore
**/jsconfig.json
**/.eslintrc.json
**/__tests__/**
.sfdx
.sfEdge cases to know
- Out-of-band changes. If someone edits production directly, the next promotion can overwrite that edit, or fail on a conflict. Treat production as write-only through the pipeline.
- Stage drift. If an environment is refreshed or changed by hand, it no longer matches its branch. Compare branches in Git first, then check the org.
- Partial success. Salesforce deployments are all-or-nothing by default. If any component fails, nothing is deployed. Do not assume a half-finished promotion happened.
- Unsupported metadata. Some metadata types are not tracked by DevOps Center and must be deployed another way. The limitations chapter lists them.
A release checklist
Before promoting to production, confirm these points:
- Every work item in the batch has a merged, approved pull request.
git logshows only the commits you expect betweenmainand the UAT branch.- The UAT stage passed its tests and the business sign-off is recorded.
- No component is shared with a work item that is still waiting in an earlier stage.
- The people who support production know the deployment window.
Exercise
A team promotes work items A and B together from UAT to production. B contains an Apex class that A's flow calls, and the deployment fails on B's tests. What happens to A, and what should the team do?
Show answer
Because the two work items deploy as one unit and Salesforce deployments are all-or-nothing, nothing reaches production and both items stay in the UAT column. The team should read the test failure on the work item, fix the Apex test or the data setup in a development environment, commit it to B's work item, and promote again. They could also promote A alone if it does not depend on B, but here A's flow calls B's class, so they should be kept together.
Exercise
Before promoting from UAT to production, which Git command shows you the commits the promotion would carry, and what does an unexpected commit in the output tell you?
Show answer
git fetch origin followed by git log --oneline origin/main..origin/UAT. An unexpected commit means a work item reached UAT that you did not plan to release, or that a commit was added outside the normal work item flow. Find its work item and decide whether to include it before promoting.