Automatic PR validation for Salesforce: how to keep your branches deployable

Automatic PR validation for Salesforce: how to keep your branches deployable

Holly Bracewell on

Share with



Keeping the main branch ‘deployable’ is a common concern for Salesforce teams using source control. In other words, teams want to avoid merging changes to main — or any other long-lived branch — that won’t successfully validate or deploy to the next org in their workflow. With Gearset’s automatic pull request validation, you can merge branches knowing that your changes will validate successfully, and can be seamlessly deployed downstream.

The problem with version control for Salesforce

Version control is a key component of Salesforce DevOps. While branching strategies are customizable, all source-driven workflows involve creating feature branches for new changes then merging that development through the rest of the pipeline.

A commonly used branching strategy is the feature branch model: feature branches are created from main then new development is committed to the branch before a pull request (PR) is opened, and the changes are merged directly into main for testing and release.

Diagram of a feature branch workflow model

Adopting a source-driven workflow like the one above helps teams release more regularly and more reliably. But a recurring worry for Salesforce teams is ensuring main is ‘deployable’.

In an org-based development model, this isn’t such a big problem. You build your changes in one org, then deploy them out to another when you’re happy — if you’ve missed a dependency or you attempt to deploy something undeployable, then you’ll get a failure message then and there.

When you introduce Git to this workflow, your changes get merged to main when you’re happy with them, but they’re only tested for deployability at the point that branch gets deployed to an org.

Keeping main deployable is usually a bigger concern for teams using a feature branch model as there are no other long-lived branches in their workflow, so any breaking changes that are merged means their source of truth is no longer usable.

Glaziers Hall, London

DevOps Dreamin’ London 2024

Find out more

Speed up issue detection with continuous integration

Using continuous integration to monitor your main branch and automatically deploy any changes to a staging environment can help. When a feature branch is merged into main, your CI tool will detect the change to the branch, package up your changes and push them out to your staging org. At this point you’ll receive a failure notification if you’ve merged breaking changes.

But setting up CI to push changes to a testing environment is only a partial fix — while you find out about the breaking changes quickly, you’ve still got a main branch that’s broken and undeployable until those changes are fixed.

Automatically validate your PRs with Gearset

Wouldn’t it be better if you could have confidence that your changes were deployable before merging a pull request into main? As part of Gearset’s CI/CD solution for Salesforce, CI jobs can be set up to automatically validate PRs prior to merging to catch breaking changes before you merge.

Gearset detects when a PR is opened against your selected branch — such as main or UAT — and begins running validation checks by simulating deploying the new changes in advance but without actually pushing any metadata. This gives your team more time to make fixes and avoid merging breaking changes altogether.

Gearset users are seeing big time-saving benefits by including automatic validation of PRs in their deployment process. Jim Young, Director of Systems at ETE Reman, told us: “This will save literally hours of unplanned work ... It has already caught two pull requests that would have made it through review and clogged up our deployment chain.”

Once the PR is merged, the same CI job will automatically build and deploy your changes to the target org.

If you’re ready to get started with Gearset’s automatic PR validation feature, you can start a free 30-day trial today.

How to set up automatic validation of pull requests

Automatic validation of pull requests is supported for the following version control systems:

Setup is quick and easy: when creating a CI job in Gearset, simply check the Validate pull requests targeting the source branch box. You can also choose to receive a notification about the outcome of the validation too.

Screenshot of CI job setup interface

When your CI job is saved, Gearset will give you the option to set up the webhook automatically or walk you through the steps to configure the webhook manually.

Once enabled, Gearset displays any pull request validations right underneath the associated CI job in the CI jobs overview list view.

Screenshot of automatic PR validation in CI job list view

If you’re using Pipelines, Gearset’s Salesforce CI/CD solution, you’ll be able to check the status of validations there too.

Screenshot of automatic PR validation in pipelines view

The outcome of the validation will also flag on the PR in your version control system.

Take your Salesforce DevOps to the next level

If you’re keen to learn more about the practical skills needed to succeed with Salesforce DevOps, take the free Salesforce DevOps Fundamentals Certification. Covering version control, automation, testing and backup, you’ll come away with the knowledge and skills needed to reach Salesforce DevOps maturity.

If you’re looking for tailored advice about your workflow and the best next steps for your team, schedule time with our DevOps experts.

Ready to get started with Gearset?