Sub topic 6
Designing a pipeline and its stages
This chapter assumes you have completed the earlier chapters on enabling DevOps Center, creating a project, and connecting environments and the repository. You should know what a sandbox is, how Git branches and merges work, and how a Salesforce org differs from a repository.
What a pipeline is
A pipeline is the ordered path a change follows from its first test environment to production. It belongs to a DevOps Center project and is made of stages. Each stage ties together two things:
- An environment, which is a Salesforce org such as a sandbox or production.
- A branch in the project's Git repository.
The branch records what the stage should contain. The org holds the deployed result. When you promote a work item, DevOps Center merges the change into the next stage's branch and deploys it to that stage's org.
Because of this pairing, you design a pipeline in two layers at once. You decide which orgs a change passes through, and you decide which branches hold the code in between.
The stage model
The first stage receives changes after they pass pull request review. The last stage usually maps to production and to your main branch. Stages in between exist for validation: integration testing, user acceptance testing (UAT), or staging.
Developers do not work inside a stage. They work in development environments, which are sandboxes attached to the project, and their changes enter the pipeline through a work item branch. The stages after that are only for validation and release.
Choosing the stages
There is no fixed number of stages. Add a stage when it answers a question that no earlier stage can answer. Use this table as a starting point.
| Stage | Question it answers | Typical sandbox type |
|---|---|---|
| Integration | Do changes from several developers work together? | Developer or Developer Pro |
| UAT | Do business users accept the change? | Partial Copy or Full |
| Staging | Does the release behave with production-sized data and a final regression run? | Full |
| Production | Is the change live? | Production org |
A small team with one admin often needs only Integration and Production. A regulated team may add UAT and Staging so that each approval has its own checkpoint.
Each extra stage adds cost. It needs a sandbox to maintain and refresh, and each promotion takes time. Stages also make it more likely that a change sits in one stage while later work moves ahead, so the stage branches drift apart.
Match sandbox type to purpose
Pick the sandbox license for what the stage tests, not for convenience.
- Use a Developer or Developer Pro sandbox for an integration stage that checks metadata only.
- Use a Partial Copy or Full sandbox for UAT when testers need realistic records.
- Use a Full sandbox for staging when you need production-scale volumes, such as for performance checks.
Full sandboxes have a long refresh interval, so check when the next refresh is allowed before you plan a refresh around a release date.
Stage branches
When you create the pipeline, DevOps Center creates or uses one branch per stage. The production stage normally uses main. Other stages get their own branches, such as Integration or UAT.
The ordering of stages gives the branches a direction. Code flows from the first stage toward production, so the earlier branches should contain everything the later ones do, plus changes still in progress. You can check this in Git. This command lists commits that have reached UAT but not yet main, which is what the next promotion would carry:
git fetch origin
git log --oneline origin/main..origin/UATAn empty result means UAT and main hold the same work. A long list means many changes are waiting, and the release is larger and riskier than it needs to be.
The repository itself should follow source-driven layout. A minimal sfdx-project.json defines the tracked directory:
{
"packageDirectories": [
{ "path": "force-app", "default": true }
],
"namespace": "",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "62.0"
}A .forceignore file keeps tooling files out of deployments, so only real metadata travels through the stages:
# .forceignore
**/jsconfig.json
**/.eslintrc.json
**/__tests__/**
.sfdx
.sfDesign rules that prevent trouble
- Keep one path to production. Every change should pass through the same stages in the same order. A second route, such as a direct deploy from a developer sandbox, makes the branches disagree with the orgs.
- Name stages by purpose, such as "UAT", not by org name. Orgs get refreshed or replaced. The purpose stays.
- Keep stage environments free of manual changes. If someone edits a UAT org directly, the org no longer matches its branch. The next promotion may overwrite the edit or fail.
- Decide who may promote from each stage before you decide how many stages you need. The approver for UAT is often a business owner, not a developer.
- Keep the pipeline short enough that a change can reach production within your release cycle.
Common errors
- A stage is connected to the wrong org. The pipeline then deploys to the wrong place. Check the org name and its login URL on the environment before you add it to a stage.
- The same sandbox is reused for two purposes. Using one sandbox for both development and a pipeline stage mixes untested work into the stage. Keep development environments separate from stage environments.
- The production branch is not the default branch. Reviews and comparisons then run against the wrong baseline.
- Stage branches drift. Hotfixes applied directly to
mainand not merged back leave earlier branches missing changes. The next promotion can then reintroduce a bug or cause conflicts.
Checking your design
Before you accept a design, walk one imaginary change through it and answer these questions:
- Where does the change first run alongside other developers' work?
- Who signs off before it reaches users, and at which stage?
- Which stage can reproduce a production-like load or data set?
- If the change fails at the last stage, what has to be undone, and where?
If you cannot answer one of these, the pipeline is missing a stage or has too many.
Exercise
A team has a development sandbox for each developer and a single Full sandbox. They want Integration, UAT and Staging stages. What is wrong with using the Full sandbox for all three, and what is a better design?
Show answer
One org can map to only one place in the pipeline at a time, and it can hold only one version of the code, so it cannot show Integration, UAT and Staging as separate states. Changes from different stages would overwrite each other, and the stage branches would no longer match what the org contains. A better design is to give Integration a Developer or Developer Pro sandbox, give UAT a Partial Copy sandbox if records are needed, and keep the Full sandbox for Staging. If the team cannot afford those orgs, it should drop stages. For example, it could use Integration (the Full sandbox) and Production.
Exercise
You run git log --oneline origin/main..origin/UAT and it prints 14 commits. What does that tell you about the pipeline, and what would you do about it?
Show answer
Fourteen commits have reached UAT but not main, so the next promotion to production will carry all of them. That is a large release. You would check which work items those commits belong to, finish testing or approval for them, and promote them in smaller batches. You would also look for a UAT sign-off delay that is holding changes back.