Resources /
Blog

How to Build a Salesforce Continuous Integration Pipeline

Submit your details to get a book

12
Min Read
Resources /
Blog

How to Build a Salesforce Continuous Integration Pipeline

Download

Submit your details to get a book

12
Min Read
Glowing rising bar chart on a round platform, linked to branch, code, check, clock and sync tiles
Glowing rising bar chart on a round platform, linked to branch, code, check, clock and sync tiles

A Salesforce CI/CD pipeline commits each change to version control, validates it against a target org, runs your Apex tests and promotes it to production. Continuous integration catches conflicts early, and continuous delivery or deployment moves validated metadata from sandbox to production without change sets.

CI/CD is one part of Salesforce DevOps, and on Salesforce it has to carry the configuration your admins build as well as your developers' code.

What Is CI/CD in Salesforce DevOps?

At the broadest level sits Salesforce DevOps: the culture, processes and tooling a team uses to plan, build, test and release changes to an org. Continuous integration, continuous delivery and continuous deployment are practices inside that discipline, and a CI/CD pipeline is the automation that carries them out.

Complexity is one reason to automate: in the 2024 SF Ben Developer Survey, 53% of Salesforce developers agreed that the platform is becoming increasingly complex to work with. Another 34% were neutral, and only 13% disagreed.

Three practices make up a Salesforce CI/CD pipeline. This table shows what each one automates, where it stops and what it looks like in Salesforce.

PracticeWhat it automatesWhere it stopsSalesforce example
Continuous IntegrationMerging every change into a shared repository, then validating itAt a validated branch. Nothing is promotedCommit triggers a validation-only deploy and Apex tests
Continuous DeliveryPromotion through testing and staging environmentsAt the production gate. A person approves the releaseValidated change lands in a UAT sandbox and waits for sign-off
Continuous DeploymentThe full path to production, including the release itselfNowhere. No manual gateApproved change deploys to production automatically on merge

How CI works on Salesforce

Continuous Integration (CI) merges each change into a shared repository frequently, then validates it automatically. In Salesforce development, that change includes configuration such as profiles, flows and validation rules as well as Apex code.

Admins build some of it in Setup, so CI on Salesforce rests on three things:

First, version control has to capture declarative work as well as programmatic work. If an admin changes a validation rule directly in Setup and it never reaches a branch, the next deployment replaces it, because deployed source overwrites the matching metadata in the org.

Second, validation replaces compilation, and a validation-only deployment is the closest thing to a build step. Salesforce's CLI reference says it verifies whether a deployment will succeed without actually deploying the metadata to your org.

Third, before you can deploy Apex, at least 75% of the code must be covered by tests and all of them must pass, so test execution is a gate you can't opt out of. Salesforce's own training adds that 75% is the lowest coverage it requires, not a target.

Continuous delivery and continuous deployment

Continuous delivery picks up after CI and moves tested changes through sandbox environments, where UAT and integration tests catch problems before release. Under continuous deployment, each verified change then goes on to production with no manual gate.

Six Stages of a CI/CD Pipeline, From Version Control to Rollback

This guide splits a CI/CD process into six stages, whatever tool runs it. Each stage exists to catch a class of failure the previous stage can't.

Source control comes first, then automated testing on each commit or pull request, covering Apex unit tests and static code analysis. Validation follows, which Salesforce's Operational Excellence guide describes as running the deployment as a dry run without committing changes.

Deployment promotes the validated change, and gating production behind an approval, as in these release management best practices, is the safer default. Monitoring then watches error rates, failed jobs and user reports in the hours after release.

For rollback, the same guide says Salesforce metadata is rolled back by redeploying the previous version rather than with a rollback command. It recommends pre-deployment backups for data changes, so you can restore from them.

The table below sums up all six stages, from source control through to rollback, and the failure each stage is there to catch. Each stage assumes the one before it worked, so a process without validation fails at deployment and one without rollback fails at recovery.

StageWhat happensFailure it catches
1. Source controlEvery change lands in a branch before moving anywhereUntracked changes and no way to compare intended state to actual
2. Automated testingApex unit tests and static analysis run on commit or pull requestBroken logic and code-quality rule violations
3. ValidationValidation-only deploy runs against the real target org without committingMissing dependencies, component conflicts and invalid references
4. DeploymentValidated change promotes to the target environment, gated or automaticUnreviewed changes reaching production
5. MonitoringError rates, failed jobs and user reports are watched after releaseDeployments that succeed technically but break behavior
6. RollbackRestore from a pre-deployment backup snapshotData loss that redeploying a previous commit can't reverse

Underneath the stages sit five CI/CD components: version control, branching, automated testing, monitoring loops and deployment automation (in place of manual deployments through change sets). Version control lets developers work on several features at once on separate branches, then resolve any merge conflicts before release.

How to Build a CI/CD Pipeline in Salesforce with Flosum

Salesforce has no build artifact in the usual sense. The pipeline moves metadata between long-lived Salesforce environments that already hold configuration, data and users, and since they drift apart, a generic CI/CD tool needs its own scripts to handle that.

Flosum DevOps runs in Flosum's cloud or in your own cloud. It treats Git as optional, not mandatory, and each Flosum pipeline connects a branch to one or more orgs with steps for validation, testing and deployment.

Stage #1: Create CI/CD Pipeline in Flosum

Creating it takes three steps, and you add the operations afterward. Open Pipelines from the left sidebar and click Create pipeline, then type a name in the Pipeline name box and click Create pipeline a second time.

Flosum's docs suggest naming each one after its job, for example Release-Branch-Pipeline, and tying it to a stable integration or release branch. Connect only the orgs it actually needs, which reduces unnecessary runs.

Stage #2: Add Pipeline Steps

Each step is one operation you configure (Validate, Code Scan or Migrate Data, for instance), and it names the step that runs next when it passes or fails. Adding a step works the same way whichever operation you pick.

  1. Open the pipeline on the Pipelines page.
  2. Click the + icon between two steps, and give the new step a name.
  3. Pick the operation from the Operation dropdown, then choose the target org.
  4. On a Validate step, you also pick the Apex test level from the Run tests dropdown.
  5. Set On pass and On fail to whichever steps should run next, and click Add.

You don't have to save as you go, because your work saves itself after every change. Flosum's docs add one warning: don't set both On pass and On fail to Stop on any step but the last, or a step with no path to it gets removed.

A Validate step checks the changes without committing anything to the target org. For safer automation, the docs suggest routing its On fail result to a Rollback operation.

Stage #3: Execute a Pipeline

You can run a pipeline from the pipeline editor, from a branch or from the Pipelines page. From the pipeline editor, it takes three steps.

  • Go to Pipelines in the left sidebar and open the pipeline.
  • Select Run pipeline and pick the branch to run it for.
  • Click Run.

Seeing a "Pipeline ran successfully" message only means the job started, not that every step passed. To see the results, open the branch under Code and go to its Activities tab, where each step shows as Completed or Exception with its logs.

Continuous Integration Software for Salesforce: Build or Buy?

The table compares five broad options, and the right one depends less on features than on who will maintain the CI/CD tooling.

ToolSalesforce awarenessWho maintains itFits when
Salesforce DevOps platformBuilt in: metadata model, conflict detection, deployment orchestrationThe vendorAdmins need to take part in releases alongside developers
Salesforce DX / sf CLISalesforce's own commands, but no orchestration layerYour teamYou want a foundation for a custom pipeline
GitHub ActionsNone by default. You write the Salesforce logicYour teamCode already lives in GitHub and the team is comfortable with YAML
Azure DevOpsNone by defaultYour teamThe organization is standardized on Microsoft tooling across several platforms
JenkinsNone by defaultYour team, including the serverMaximum control is required and dedicated engineering capacity exists

Custom pipelines can build on Salesforce DX and the Salesforce CLI. Open source and scriptable, the sf CLI isn't a CI system by itself: it provides the commands, and you supply the orchestration.

General-purpose CI/CD systems such as GitHub Actions, Azure DevOps or Jenkins give you flexibility and expect you to supply the Salesforce expertise. By contrast, a Salesforce-specific DevOps tool supplies that expertise and expects you to work within its model.

Because tools like Jenkins and the sf CLI are open source, assembling your own toolchain can look cheap. License cost is only part of the picture, though, and our build vs buy guide covers the trade-offs in depth.

Upkeep continues after launch, because Salesforce has three major releases a year with new features and other updates. Buying moves that upkeep to the vendor.

Build when the setup is a differentiator, and buy when it's infrastructure. Be honest about which one it is for your team.

How to Build a CI/CD Pipeline with GitHub Actions

GitHub Actions lets you build a Salesforce CI/CD pipeline without buying a dedicated platform. Its pieces are simple: your metadata lives in a GitHub repository, a workflow file defines what runs and when, and GitHub-hosted runners execute the Salesforce CLI against your orgs.

Authentication is the step that needs the most care, because the job runs unattended on a runner. Salesforce's OAuth JWT bearer flow authorizes servers to access data without logging in interactively each time.

Generate an RSA key pair, upload the X.509 certificate to Salesforce, and store the private key and consumer key as GitHub Actions secrets. Each run then authenticates at the start without a login prompt.

One change to plan for: Salesforce Help says that from Spring '26, new Connected Apps can't be created unless you request the option from Salesforce Support. Existing Connected Apps keep working, but new setups belong on External Client Apps, which also support the JWT bearer flow.

Use the sf CLI (v2), which Salesforce's CLI repository says went GA in July 2023 and understands both sfdx and sf commands. The same page links Salesforce's guide to moving from sfdx (v7) to sf (v2), so skip tutorials built on the old sfdx force: commands.

Workflows are YAML files in the .github/workflows directory, and triggers determine the workflow's shape. Run validation on pull requests targeting your integration branch, and run deployment on merge to that branch, with a validation-only deployment so nothing is committed until the check passes.

YAML: .github/workflows/salesforce-ci.yml
name: Salesforce CI

on:
  pull_request:
    branches: [ integration ]   # validate only
  push:
    branches: [ integration ]   # deploy on merge

jobs:
  salesforce:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0        # full history for delta tooling

      - name: Install Salesforce CLI
        run: npm install --global @salesforce/cli

      - name: Authenticate (JWT bearer flow)
        run: |
          echo "${{ secrets.SF_JWT_KEY }}" > server.key
          sf org login jwt \
            --client-id "${{ secrets.SF_CONSUMER_KEY }}" \
            --jwt-key-file server.key \
            --username "${{ secrets.SF_USERNAME }}" \
            --instance-url "${{ secrets.SF_INSTANCE_URL }}" \
            --alias target-org
          rm -f server.key

      - name: Validate (pull request only)
        if: github.event_name == 'pull_request'
        run: |
          sf project deploy start \
            --target-org target-org \
            --dry-run \
            --test-level RunLocalTests \
            --wait 60

      - name: Deploy (merge only)
        if: github.event_name == 'push'
        run: |
          sf project deploy start \
            --target-org target-org \
            --test-level RunLocalTests \
            --wait 60

Two practices save a lot of debugging time. Set fetch-depth: 0 on the checkout step, because the checkout fetches a single commit by default and delta tools such as sfdx-git-delta need enough history to find where two branches meet.

Also prefer RunLocalTests over RunAllTestsInOrg, which per the Salesforce CLI reference also runs the tests of managed packages. Set up this way, GitHub Actions gives you a working Salesforce CI setup, provided your team is willing to own the YAML and the auth setup.

FAQs

Is CI/CD different from DevOps?

CI/CD is part of DevOps, not the same thing: a set of practices that automate integrating and deploying code changes across the development life cycle. Broader than that, Salesforce DevOps is the wider discipline that brings development and operations work together across the whole release process.

What does CI stand for in Salesforce?

CI stands for Continuous Integration, where developers and admins add changes to the source code repository and automated checks test them. Builds, validation-only deployments and Apex tests catch bugs and incompatibilities before they reach production.

What is CI/CD used for?

CI/CD is used to build a pipeline that automates and speeds up developing, merging, validating and releasing changes. In Salesforce it also handles metadata promotion between sandboxes and production.

What is Salesforce continuous integration?

It means merging every change into a shared repository and validating it automatically, which on Salesforce covers metadata as well as code. That puts the weight on capturing declarative admin work in version control, on validation-only deploys to a target org and on Apex tests that meet the 75% coverage requirement.

How do you build a CI/CD pipeline?

Build it in six stages: source control, automated testing on commit, validation against the target org, deployment, monitoring after release and rollback from a backup snapshot. Order counts, because each stage catches a class of failure the previous one cannot.

How do you build a CI/CD pipeline with GitHub Actions?

Keep metadata in DX source format in a GitHub repository and authenticate headlessly with the OAuth JWT bearer flow, an External Client App and GitHub Actions secrets. Your workflow file in .github/workflows then runs validation-only deploys on pull requests and full deploys on merge, using the sf CLI (v2) rather than the older sfdx commands.

What are the best continuous integration tools for Salesforce?

You can choose from Salesforce-specific DevOps platforms, Salesforce DX with the sf CLI, GitHub Actions, Azure DevOps and Jenkins, and none is best for everyone. General-purpose CI systems offer flexibility but leave the Salesforce expertise to you, while Salesforce-specific platforms bring that expertise and ask you to work their way.

What is the difference between continuous delivery and continuous deployment?

Both automate everything up to production, and continuous delivery keeps each change deployment-ready while a person approves the final release. Continuous deployment sends validated changes to production automatically, with no manual gate.

Why is continuous integration important for Salesforce development?

Admins and developers change the same components in parallel in shared, long-lived Salesforce orgs, so without CI, conflicting work turns up at deployment time. Continuous integration surfaces those conflicts soon after a commit, so they can be fixed before release.

What are the benefits of CI/CD in Salesforce?

Automated tests and validation flag faulty changes in UAT or staging rather than in production, and every change is tracked in version control. Developers and admins can also work on separate features in parallel on their own branches.

Should you build or buy a Salesforce CI/CD solution?

Buy when the pipeline is infrastructure your team simply needs to work, and build when your release process is unusual enough to set you apart. Rather than license cost, what decides it is whether you have people who can own metadata-aware tooling through three Salesforce releases a year.

Book a demo to see how Flosum's DevOps Cloud App runs Salesforce CI/CD with fewer manual steps.

Table Of Contents
Author
Stay Up-to-Date
Get flosum.com news in your inbox.

Thank you for subscribing

Ship Salesforce changes faster
Teams on Flosum report 40% higher development velocity and 75%
fewer merge conflicts.
Free to start  |  No credit card required