Building a CI/CD pipeline for Salesforce can be a daunting challenge. Even if you’re familiar with your chosen version control provider and have built pipelines for other platforms, Salesforce is different. A fast-flowing and reliable pipeline is possible, but it really helps to have the right tools and expert guidance.
In this post we’ll look at how to build a Salesforce deployment pipeline using Gearset’s tight integration with GitHub Enterprise (GHE), allowing you to automatically deploy metadata along the pipeline.
Benefits of version control and CI/CD
Version control is a crucial pillar of Salesforce DevOps, allowing you to track and merge changes much more easily.
With version control established as your source of truth and confidence that you have repeatable and reliable deployments, you can automate your pipelines with continuous integration and continuous delivery (CI/CD). This accelerates your release process, automates more testing and validation, and helps you to catch issues early on.
Continuous integration (CI) is all about developers merging their work early and often, triggering automation that pushes the latest changes to a sandbox environment for testing. Continuous delivery (CD) focuses on iteratively releasing small changes to live environments, to deliver value to end users as quickly as possible. CI/CD ultimately tightens feedback loops and streamlines the release process — saving time and money.
Why GitHub Enterprise?
When you’ve decided to use version control to track your metadata changes, one of the first things you’ll need to decide is where to host it. You have a few different options: hosting your source code in a repository on-site, in the cloud, or self-hosting. Organizations in the healthcare or finance sector may want to opt for on-site hosting to have direct control over their data, but this can come with some restrictions. Thankfully, GitHub Enterprise (GHE), a tier of one of the most popular cloud-hosting services, is aimed towards companies who need more control over their processes.
GitHub Enterprise is:
- Self-hosted, which gives an added level of control and security compared with the cloud-based GitHub.
- Scalable, with the option to increase org limits, repos and data and metadata usage.
- Customizable, with a variety of integrations available.
- Prioritized for support by GitHub, with dedicated support and service level agreements which promise quicker response times and help to resolve critical issues fast.
GitHub Enterprise gives you all the functionality of GitHub while allowing you to store your data on self-hosted servers like AWS, Azure, or your own on-prem hardware.
Can we build a CI/CD pipeline with generic tools?
To manually build an automated pipeline with GitHub Enterprise for your Salesforce release process, you’ll need a few different tools.
When building out your pipeline, you’ll need to use your chosen automation/orchestration tool to fetch the Salesforce DX project from the repo and then use the SFDX CLI to run commands to build your project. This could be locally in a tool like VSCode, or inside cloud-runners that GitHub Actions would provide.
Building your own Salesforce CI/CD pipeline is a very long, manual and expensive process. And the manpower needed to maintain the pipeline once it’s built can be a huge cost, especially if something breaks unexpectedly — including keeping up with new releases and functionality that Salesforce release, along with any changes the automation platform may introduce that could affect your workflows.
How does Gearset integrate with GitHub Enterprise?
Gearset supports all Git-based providers, such as GitHub, Bitbucket, AWS CodeCommit, Azure DevOps, and GitLab, but in this walkthrough we’ll talk specifically about GitHub Enterprise. You can sign up for a free trial of Gearset and follow along with these steps.
It’s really easy to hook up your GitHub Enterprise repo to Gearset.
In GitHub Enterprise
Note: Only one person in the team needs to complete these steps in GitHub Enterprise.
Under OAuth Apps in the Developer settings, click Register new application. Enter the following:
- Application name:
Gearset
- Homepage URL:
<https://app.gearset.com>
- Authorization callback URL:
<https://app.gearset.com/authorization/github-enterprise/callback>
Click Register application and take note of the Client ID and the Client Secret. We’ll need these at the next stage!
In Gearset
Go to the Source control and services page and click + Connect to GitHub Enterprise Server.
Fill in the URL of your GitHub Enterprise instance and your Client ID and Client Secret then press Connect.
Once complete, you’ll be redirected back to Gearset and you’ll now be able to use GitHub Enterprise Server repositories as the source or target for deployments.
Build your CI/CD pipeline with Gearset
Once you’re all set up and have connected your GitHub Enterprise with Gearset, it’s time to get hands on with Pipelines, our solution for end-to-end management of your Salesforce release process. For this walkthrough, we’ve used a fictional company called NextGen Innovations.
With Pipelines, you get full visibility and control over your release process — end to end. Each environment in the Pipelines view represents a branch backed by a Salesforce org. You can read about the Pipelines branching model in our documentation.
Add a new pipeline
Open the Continuous integration page from the left hand side menu. In the top right, click Pipelines. Click the + sign in the top left, and then Add new pipeline.
Select your GitHub repo
Create your pipeline, name it and select GitHub Enterprise Server as your repository type. Your repo should then appear in the drop-down. Click Save and then Add webhook. Gearset will automatically create one for you or you can set one up manually.
Create new environment
Next, click Create environment and then select Create new environment/job. Follow Gearset’s CI job wizard through the next steps to configure your job.
Add more environments
Add as many environments as you need, clicking + Add environment in the top right.
Edit your environments
Once you’ve added your environments, and any sandboxes you need, click Edit environments in the top right corner and arrange your environments in order.
Link your environments
Link the environments together by dragging the circles to the next one you want in the pipeline. When you’re happy, click Save changes.
Now Gearset is in a position to work alongside GHE and allow the creation of feature branches, raising pull requests, and automatically promoting your Salesforce changes as you merge into each environment, giving you an all-encompassing CI/CD workflow. Gearset will also respect to any git branch protections you have in place with your chosen VCS, not just GitHub enterprise.
Get started today!
Building a reliable CI/CD pipeline for Salesforce with GitHub Enterprise doesn’t have to be difficult, thanks to Gearset’s Pipelines. To see Pipelines in action, take a look at this video recording, or book a demo with our DevOps experts.