Resources /
Blog

How to Build a Salesforce Continuous Integration Pipeline

Submit your details to get a book

9
Min Read
Resources /
Blog

How to Build a Salesforce Continuous Integration Pipeline

Download

Submit your details to get a book

9
Min Read
Illustration of a speed gauge on a hexagon platform, linked to branch, code, clock and sync tiles
Illustration of a speed gauge on a hexagon platform, linked to branch, code, clock and sync tiles

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

CI/CD is one part of Salesforce DevOps. It's harder on Salesforce than on most platforms, because much of what changes is admin-built metadata rather than 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.

That automation counts for more in Salesforce development because of how much complexity teams manage. 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. Automating the build, test and release steps tackles slow development and recurring bugs, with faster merging, fewer overwrites and easier branch management.

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, most of that change is XML metadata such as profiles, flows and validation rules.

Admins build much of it rather than developers, 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 silently overwrites it.

Second, validation replaces compilation, and a validation-only deployment is the closest thing to a build step. It runs the full deployment against a target org and reports what would happen without committing anything.

Third, deploying Apex to production requires at least 75% code coverage org-wide, so test execution is a gate you can't opt out of. Catching issues this early means problems become small, same-day fixes instead of release-week emergencies.

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

Every pipeline shares the same six stages in the same order, whatever tool runs it. Each stage exists to catch a class of failure the previous stage can't.

App development process in Salesforce with Flosum

Source control comes first, then automated testing on each commit or pull request, covering Apex unit tests and, more and more, static code analysis. Validation is the stage Salesforce teams can't skip, because it runs the real deployment against the real target environment without committing it.

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.

Rollback is the stage teams skip until the first time they need it. Nothing in Salesforce versions your org for you, and redeploying a previous commit only reverts metadata, not the data that referenced the new schema.

Any real rollback plan depends on a pre-deployment backup snapshot you can restore from. Six stages, and the failure each one catches, are summed up in the table below.

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 policy violations such as a profile granting Modify All Data
3. ValidationValidation-only deploy runs against the real target org without committingMissing dependencies, field references absent in the target, profile conflicts
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

Each stage assumes the one before it worked, so a pipeline without validation fails at deployment and one without rollback fails at recovery. Our guide to CI/CD pipelines that hold up under real release pressure covers what tends to break in production.

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). Get them right and you improve collaboration and code quality, since version control lets developers work on several features at once without merge conflicts.

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, generic CI/CD tooling often needs heavy scripting.

Salesforce application development flowchart in Flosum

Flosum DevOps comes in three deployment options. Salesforce-native runs as a managed package inside your org, Flosum-hosted cloud runs on Flosum's infrastructure, and customer-hosted suits regulated or sovereign environments.

None of them requires Git, since Flosum treats Git as optional, not mandatory. Each Flosum pipeline connects a branch to one or more orgs and sets out the 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 with its own settings (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 Pipelines page, 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 Tools for Salesforce: Build or Buy?

Most teams choose between five broad options, and the right one depends less on features than on who will maintain the CI/CD pipeline.

ToolSalesforce awarenessWho maintains itUsually chosen when
Salesforce-native DevOps platformBuilt in: metadata model, conflict detection, deployment orchestrationThe vendorAdmins need to participate, or work must stay inside the Salesforce trust boundary
Salesforce DX / sf CLINative commands, but no orchestration layerYour teamUsed as the foundation underneath any 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

Everything else builds on Salesforce DX and the Salesforce CLI. Free 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-native DevOps tool supplies that expertise and expects you to work within its model.

Because many of these CI/CD tools are free or open source, assembling your own toolchain can look cheap. License cost is rarely the deciding factor, though, and our build vs buy guide covers the trade-offs in depth.

Paying people to maintain those tools adds up over time. One McKinsey study with the University of Oxford covered more than 5,400 IT projects.

Large ones, with budgets above $15 million, ran on average 45% over budget and 7% over time, while delivering 56% less value than predicted. Most in-house builds are far smaller, but the underlying causes, unclear scope and shifting requirements, scale down just as reliably.

Upkeep never stops either, because Salesforce keeps updating its metadata types and has three major releases a year. Buying moves that burden to the vendor, who tracks metadata and API changes as part of its own release cycle.

Build when the pipeline 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 is a common way to 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 hosted runners execute the Salesforce CLI against your orgs.

Authentication is the step that needs the most care. GitHub runners have no browser, so interactive login is not an option.

Instead, the supported pattern is the OAuth JWT bearer flow. Generate an RSA key pair, upload the certificate to Salesforce, store the private key and consumer key as GitHub encrypted secrets, and authenticate headlessly at the start of each run.

One change to plan for: Salesforce Help says that from Spring '26, new Connected Apps can't be created unless Salesforce Support turns the option on. 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), since Salesforce recommends moving from sfdx (v7) to sf (v2). Many tutorials online still use the old commands that begin with sfdx force:.

Workflows are YAML files in .github/workflows, and triggers determine the pipeline'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 deployment tools need full git history to calculate a diff.

Also prefer RunLocalTests over RunAllTestsInOrg, which per the Salesforce CLI reference also runs managed package tests and slows every run for no benefit. Set up this way, GitHub Actions gives you a working Salesforce pipeline cheaply, 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 discipline that brings development and operations teams together for faster time to market and continuous improvement.

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, which is otherwise a slow and error-prone manual process.

What is Salesforce continuous integration?

It means merging every change into a shared repository and validating it automatically, which on Salesforce mostly means metadata rather than 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 a production-like 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 encrypted 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-native 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-native 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, which keeps small problems small and makes release dates predictable.

What are the benefits of CI/CD in Salesforce?

Teams ship faster and catch problems earlier, because automated tests and validation flag faulty builds in UAT or staging rather than in production, where fixes cost more. Code quality improves too, and developers and admins can work on separate features in parallel without clashing.

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 discovery call to see how Flosum 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