Skip to content
Promote Force
Docs: Deploying safely

Docs

Deploying safely

Signed in? Open this page in the app, with links straight to your team's screens.

Nothing deploys without the approvals its stage asks for, every deploy can be undone, and the settings each org needs stay out of Git.

Approval gates and designated approvers

Every promotion path has gates: a check-only validation, code analysis and approvals. A promotion can only join the merge queue once its checks are green and its approvals are in. Set the approval rules per path in the target stage’s Settings tab, under Gates → Approval policy (owners, admins and release managers).

  • Required approvals: how many approvals the promotion needs. Only approvals on the current head commit count, and the author doesn’t count (unless the admin override below applies).
  • Required reviewers: members who must each approve, like code owners (for example the tech lead). Each also counts toward the required approvals, so the path needs at least one approval per required reviewer. Only members who can approve into the stage can be picked.
  • Only designated approvers count: only members with an explicit Approve tick under the stage’s Permissions, and the required reviewers, count. Owners’ and admins’ implicit approve rights don’t; tick Approve for an owner or admin to designate them.
  • Unresolved review threads block approval (off by default): every review thread must be resolved before the promotion can be queued.

The review page, the promotion’s timeline and the promote dialog say what is still missing, for example “Waiting for Lena Fischer (required reviewer)” or “1 of 2 approvals from designated approvers”. Required reviewers are told when their approval is required.

When the author is a required reviewer. Authors can’t approve their own promotion (owners and admins can when the admin override is on). If the author is a required reviewer, their slot stays in the count, so another (designated) approver has to approve in their place.

Admin override

Under Settings → Team → Approvals, owners and admins can turn on Admins can approve their own promotions (on by default). With it on, an owner’s or admin’s approval on the current head:

  • counts on their own promotion (they still can’t request changes on it);
  • counts on paths with Only designated approvers count, and meets the required approvals and every required reviewer by itself;
  • doesn’t clear objections: change requests and, when the path blocks on them, unresolved threads still block. Production minimums and every other gate still apply, and a new push dismisses the approval like any other.

The review page and the promotion’s timeline show an Admin override badge and say who approved, for example “Approved by Ola Owner (admin override)”. Every override, and every change to the setting, is recorded in the audit log. Turning the setting off makes overrides stop counting straight away: promotions that relied on one go back to awaiting review, and leave the queue if they were in it.

Approvals are checked again after enqueue. If a reviewer requests changes, an approver loses approve rights, a required reviewer is added or the path gets stricter while a promotion waits in the queue, it goes back to awaiting review with the reason, and its author is notified. The merge queue also checks every promotion right before it deploys a batch: one that lost its approval is taken out, and the rest of the batch is rebuilt without it. A deploy that is already running in the org is never interrupted.

Production minimums. Paths into the production stage always keep at least 1 required approval, static analysis (a severity threshold) and pre-validation. Saving a path, or marking a stage as production, that would drop below them is refused with the reason.

To require the tech lead on a stage:

  1. Open the stage’s Settings, tick Approve for the tech lead under Permissions and save.
  2. Under Gates, on each path into the stage, add the tech lead under Required reviewers, tick Only designated approvers count if owners and admins shouldn’t stand in, and save the gates. To keep owners and admins from standing in at all, also turn off the admin override under Settings → Team.

Apex tests and the test level

Every validation and deploy runs at a Salesforce test level, picked from the path’s Tests setting, the target stage and whether the package contains Apex.

  • Mapped tests runs the tests mapped to the Apex classes and triggers in the package (RunSpecifiedTests), or all local tests when Apex changed but no test could be mapped.
  • Fixed list always runs the test classes and test suites set on the path with RunSpecifiedTests, even when no Apex changed. Tick Also run the mapped tests to add the change’s mapped tests. With an empty list (or nothing in it found in the repository) the mapped-tests rules apply, except in production, which then runs all local tests.
  • All local tests and All tests in the org always run RunLocalTests and RunAllTestsInOrg.
  • No Apex in the package on a path with mapped tests: sandboxes and scratch orgs run no tests (a NoTestRun dry run, then a plain deploy).
  • Production never skips tests. A package without Apex runs local tests in production, and a path into production set to a fixed list needs at least one test class or suite.

Tests are mapped from the change in three ways: test classes in the package, naming conventions (Foo runs FooTest, Foo_Test, FooTests and Foo_Tests), and the project’s test mapping rules on the project page, such as “when OrderTrigger changes, run OrderServiceTest” or “when Order* changes, run OrderSuiteTest”. Owners, admins and release managers edit the rules; stage monitors use them too.

A Salesforce deploy only takes test class names, so test suites on a fixed list are expanded from the ApexTestSuite files in the repository (testSuites/*.testSuite-meta.xml), wildcards included. Rule and fixed-list tests that aren’t test classes in the repository are skipped with a warning. The validation’s Testing and coverage section and its run page list every test that ran and why, with the final test level.

A repository can keep its rules in .promoteforce/tests.yaml; Import on the test mapping reads it from main into the editor, and saving makes them the project’s rules. The saved rules are what deploys use: the file isn’t read during a deploy.

rules:
  - when: OrderTrigger        # a class or trigger, or Order*
    run: [OrderServiceTest, OrderTriggerTest]
  - when: "Billing*"
    run: BillingSuiteTest     # one test or a list

Rolling back a deploy

Before every merge-queue deploy, Promote Force saves the target org’s current version of each component the deploy changes or deletes (the snapshot). Rolling back deploys that snapshot back:

  • components the deploy changed go back to their earlier version;
  • components the deploy deleted are re-created;
  • components the deploy added are deleted again (through destructiveChangesPost.xml).

Promote Force then pushes a commit to the stage branch that reverts the batch merge, so the branch matches the org again, and moves the stage’s deployed commit to it. A release (two stages on one branch) has no merge to revert: only the deployed commit goes back.

  1. Open the stage on the pipeline canvas, then the deployed promotion in Promotion history (or the batch under Queue → Recent batches).
  2. Open Roll back. The preview lists what is restored, re-created and deleted, and the Git action.
  3. Say why, tick the confirmation (type the stage name for production) and roll back.

Good to know:

  • You need permission to promote into the stage.
  • Only the latest deploy on a stage can be rolled back. If the stage was deployed again since, roll the later deploy back first: the preview tells you which.
  • The whole batch is rolled back together, and the stage’s merge queue waits until it is done.
  • Production rollbacks run local tests; sandboxes skip tests so a rollback is quick.
  • The promotions’ authors are notified, and the audit log records who rolled back, when and why.

Promoting the change again. The stage branch now holds a revert of your change. To promote a fix, merge the stage branch into your feature branch and revert the revert (git revert <revert sha>) before pushing your fix, or the merge will keep your change out.

Promotions already opened into the next stage still carry the change. The preview lists them; cancel them if the change shouldn’t move on.

Per-stage value substitution

Some values differ per org: Named Credential endpoints, notification emails, Custom Metadata values, Remote Site URLs. Keep the developer value in Git and give each stage a replacement map. Promote Force applies it to the files it checks out right before every validation and deploy into that stage (pre-validate and the merge queue), so the package carries the stage’s values. The replaced files are never committed.

  • Files is a glob from the repository root: ** crosses folders, * stays in one. Without a / it matches the file name anywhere (*.namedCredential-meta.xml).
  • Text matches a value. In XML files it is matched and written XML-escaped, so R&D just works.
  • Regular expression works on the raw file, tags included, with \1 or \g<name> for groups. A change that would leave an XML file malformed is skipped and noted in the run.
  • Mark a value secret to store it encrypted. It is never shown again, is masked in previews and is redacted from run logs.
  • Rules apply in order; turn one off without deleting it.

Set it up in the stage’s Settings tab under Value substitution (owners, admins and release managers). Preview shows which files and lines of an open promotion into the stage would change, for the saved rules or the one you are editing. The validation run lists how many replacements were made.

A rollback restores what the org had before the deploy, substituted values included.

Pre- and post-deployment steps

Some changes need a person (or a script) before or after the deploy: turn off an integration, load reference data, reindex search. Each promotion has Pre-deployment and Post-deployment sections in its detail panel.

  • A checklist step has a title, instructions and an optional owner, who is notified. The owner, the author or anyone who can promote into the stage ticks it off.
  • A required pre-deployment step that isn’t done keeps the promotion out of the merge queue, and a batch being built sends it back to review with the reason. Optional steps never block.
  • Post-deployment steps open once the promotion is deployed; their owners (or the author) are notified then, and the steps stay on the promotion until they’re done.
  • An anonymous Apex step runs its script against the stage’s org on the runner (sf apex run), before or after the deploy. Only people who can promote into the stage can run it. It is done when the script compiles and runs, and its output and debug log are in the step’s log.

Stage owners can add step templates in the stage’s Settings tab: every new promotion into the stage starts with them. Removing a required stage step from a promotion needs promote permission on the stage. Every tick, run and change is in the audit log.