DevOps / Developers

How to Build a CI/CD Pipeline for Salesforce

By David Runciman

Digital transformation and the shift to online operations means companies are increasingly reliant on Salesforce to manage many of their operations. New business requirements and opportunities are steadily increasing the workloads for Salesforce teams. Against this backdrop, teams are turning to CI/CD to automate manual workflows, helping them to manage these growing workloads and get high-quality work released quickly to their end-users.

Before discussing how to build a CI/CD pipeline, it’s important to define more clearly what we mean by CI/CD. Although commonly used in the Salesforce ecosystem, “CI/CD” often refers to different automated processes: continuous integration, continuous deployment, and continuous delivery. It’s worth pulling these terms apart a little first before we look into the benefits and components of CI/CD.

Continuous Integration

Continuous integration (or “CI”) is about automatically moving work items along a release pipeline, through environments for combining and testing packages, before promoting them to production. Work items are brought together, tested and validated, to make sure no issues arise on their release. In this way, automated testing and validation reduce the time it takes for the team to review new work and makes sure that individual work items can be deployed successfully to a new environment at any stage in the process.

Continuous Deployment

Continuous deployment is about immediately deploying changes to a downstream environment in your release pipeline as soon as a change or work item has been approved and merged into version control. This makes sure the latest changes are immediately reflected in a testing org or, in some cases, deployed directly to production. As a means to get closer to continuous delivery, continuous deployment automatically merges each change to its target environment, as soon as it’s ready.

Continuous Delivery

Continuous delivery is the ultimate goal of CI/CD. It’s a culture or way of working (rather than a type of workflow), which is about releasing added value and new functionality to your end-users as soon after the completion of the development or customization work as possible. This reduction in lead times not only makes companies more agile and flexible in delivering work quickly to meet changing priorities but also fosters an iterative way of working. Small amounts of work are released continually, allowing for rapid feedback and easier testing than riskier, larger releases.

What are the Benefits of CI/CD?

As with any form of automation, CI/CD removes repetitive, time-consuming and error-prone manual processes, saving huge amounts of developer time that would otherwise be spent managing this process. 

While time savings are a valuable way of reducing costs, introducing automation into your process is primarily about giving your whole team a reliable way to ensure continuous delivery of high-quality work to end-users. It’s no surprise, therefore, that just under 80% of Salesforce professionals responding to the largest survey on Salesforce professionals either currently use or plan to introduce CI/CD workflows this year.

By automating as much of your development and release process as possible, CI/CD reduces manual effort and mistakes, increases development velocity, and prevents valuable work you’ve already completed from sitting around waiting to be released, allowing for a whole raft of benefits, including:

  • Fast release cadences with shorter lead times.
  • Robust, well-honed release processes that are trusted.
  • Better quality releases with fewer risks and errors.
  • Safe options for rolling back mistakes.
  • Tight feedback loops with user-driven development as a result.
  • Smart integration of testing, project tracking and other tools.

What are the Components of CI/CD?

CI/CD is almost always based on a development process rooted in version control as the source of truth for new development work. Your chosen Git branching strategy then determines how you orchestrate and coordinate parallel workstreams and multiple environments. 

Within this process, automation is used to validate deployment packages, carry out tests, and promote work items along the pipeline. Individual CI jobs can be set up with the help of a Salesforce DevOps solution like Gearset or a general automation tool like Jenkins. The CI jobs run periodically or are triggered on the merging of branches in Git and can run tests before deployments between version control and Salesforce environments.

CI/CD Toolchains vs Complete DevOps Solutions

There are many different options and tools available for CI/CD, some of which are integrated into complete DevOps platforms built specifically for Salesforce, while others are automation tools commonly used across other software stacks.

Standard automation tools used on many different platforms include:

Most of the major Git hosting platforms also offer CI/CD capabilities, such as:

Salesforce-specific tools offer CI/CD as part of their DevOps solutions:

For many Salesforce teams, choosing a complete Salesforce DevOps solution is the preferred option. While cross-platform tools give companies the flexibility to use the same toolchains they rely on to manage their releases on other platforms, there are several drawbacks to them. 

Setting up, configuring and maintaining a CI/CD pipeline requires DevOps expertise, familiarity with SFDX and typically demands substantial amounts of costly developer time. Teams that go down this route also often find they run into issues around troubleshooting CI scripts, configuring integrations and, above all, dealing with the unique complexities of the Salesforce Metadata API that can cause automated deployments to fail.

When evaluating dedicated CI/CD solutions for Salesforce, there are key points to consider. The adoption of any new automation process is inevitably going to cause some disruption as your team ramps up with the new tooling.

Getting buy-in from your team members is essential, so you’ll need the flexibility to start adding automation gradually to keep everyone on board. In other words, integration with your existing workflows is important. The questions you should consider when evaluating a Salesforce DevOps tool include:

  • How much support would you need to ramp up with the tool?
  • How quickly will your team be able to see the benefits of working with the tool?
  • Is the tool flexible enough to slot into your existing workflows?
  • How well does the tool integrate with your other services, e.g. Git hosting platforms, data backup solutions, project management systems, etc.
  • How much visibility does the tool give you into deployments along your pipeline?
  • Can you test and try out the tool yourself before purchasing licenses?
  • What additional functionality would the tool offer your team, e.g. automated change monitoring, static code analysis, SFDX integration, etc.
  • What do current users of the tool say about it?
  • What’s the price tag?

Fostering a Culture of Continuous Delivery

Adopting CI/CD into your process isn’t just about tools. Unless your team is already used to an iterative way of working, they might find it’s a challenge to switch to an automated and more agile workflow – and may not immediately appreciate the benefits of it.

To get the most out of automation, you’ll need buy-in from across your organization to make sure all stakeholders can contribute effectively to a process driven by rapid feedback and continuous improvement based on frequent small releases.

When building out a new CI/CD pipeline, it’s also important to start small. You need to make sure your team is confident about working with version control first. The more successful you are at making regular, small deployments and keeping your environments in sync, the easier it is to add automation that won’t break your pipeline.

Don’t attempt to automate deployments of large volumes of changes between version control and Salesforce environments, as they’re more likely to fail and will require manual intervention that defeats the purpose of CI/CD. You don’t want to start a new process by having to resolve a huge list of deployment errors! But once you’ve got an automated flow of incremental changes running, your environments are more likely to stay in sync, and your team will really see the benefits.

How to Get Started

As CI/CD requires an automation tool, a good first port of call is to explore the various solutions on offer. If you want to look into building your own toolchain, the Salesforce DX Developer Guide is a good place to start, with useful instructions on how to get set up with various tools. 

If you’re considering a Salesforce DevOps solution, a good first step is to try out the tool to get a feel of it first. Gearset, for example, offers a free 30-day trial for you to do just that. To get a better understanding of CI/CD and Salesforce DevOps more generally, DevOps Launchpad offers a whole range of free certification courses that will help you get to grips with key aspects of Salesforce DevOps.

The Author

David Runciman

Technical Author at Gearset, the leading DevOps solution for Salesforce.

Leave a Reply

24th - 27th November


50% off

all courses