How CI should handle stale pushes queued behind a Salesforce deployment (opens in a new tab)
You will learn the three policies for dealing with superseded pushes while a Salesforce deployment is running, and the condition that decides which are safe.
Why read this
You will also see why cancelling a deployment is only a request to Salesforce.
State-based jobs
- Compare the whole branch with the org
- Skipping a push is safe
- The sha is only a label
Delta-style jobs
- Deploy only one push's files
- Skipping a push drops its changes
- Safe only if bundled into the next run
Salesforce allows one deployment per org at a time, and a deployment with tests can take a long time. When new commits arrive during a running deployment, a pipeline that runs every job in order can spend most of its time deploying changes that a later push already contains. The article uses a 25-minute deployment and three pushes as its example, and notes that the third push would go live an hour after it was made.
The article sets out three policies. Running every job keeps a record of each merge and suits production deployments. Skipping stale waiting jobs drops the middle push but lets the running job finish, which suits busy orgs. Latest wins cancels the running job and drops the waiting ones, which suits validations on pull request or integration branches where only the newest commit matters.
The deciding condition is whether each job deploys the whole branch or only the files changed in one push. State-based jobs compare the whole branch with the org, so skipping an intermediate push is safe. Delta-style jobs deploy only one push’s changes, so skipping one would drop them unless the tool bundles them into the next run. The article also warns that cancelling is a request to Salesforce, not an instant stop, and that a small deployment can finish before the cancel arrives. Building this with GitHub Actions concurrency stops the workflow but not a deployment already submitted to Salesforce, so the script must send the cancel and wait for confirmation.
The article closes with rules for any pipeline: supersede only within the same source, handle validations and deployments separately, never supersede a rollback, and provide a way to move an urgent job to the front. Its suggested default is latest wins for validations and run every job for production deployments. The piece is written by the author of Diffbridge and includes a description of how that tool implements these options.
Read the original at dev.to (opens in a new tab)