ApexSensei

Blog

Salesforce CI/CD Explained: Deploy Code Without Fear Using Copado or Gearset

By Firus Hanov ยท ยท 10 min read

Learn Salesforce CI/CD: branching strategies, GitHub Actions pipelines, Copado vs Gearset comparison, and deployment best practices for teams of all sizes.

Salesforce CI/CD Explained: Deploy Code Without Fear Using Copado or Gearset

Nothing causes more anxiety in Salesforce development than production deployments. The midnight release, the rollback conversation, the "why are tests failing in production but not in sandbox" post-mortem โ€” developers who've been through this know the feeling.

CI/CD (Continuous Integration / Continuous Deployment) is the solution. It turns deployment from a nerve-wracking manual event into a reliable, automated, repeatable process. ๐Ÿ”ฅ


What is CI/CD in Salesforce?

Continuous Integration (CI) means every code change is automatically built, tested, and validated as soon as it's committed.

Continuous Deployment (CD) means validated code is automatically deployed to the next environment.

In practice, Salesforce CI/CD looks like this:

  1. Developer creates a feature branch and writes code in a Developer Sandbox
  2. Developer commits code and opens a Pull Request
  3. CI pipeline automatically validates metadata, runs all Apex tests, checks code quality
  4. Reviewers approve the Pull Request
  5. CD pipeline deploys to Integration or Staging sandbox
  6. After UAT sign-off, the pipeline deploys to Production

Branching Strategy for Salesforce

main (mirrors production exactly)
โ”œโ”€โ”€ release/2026.Q1 (staging branch for next release)
โ”‚   โ”œโ”€โ”€ feature/JIRA-201-new-lwc-dashboard
โ”‚   โ”œโ”€โ”€ feature/JIRA-202-account-trigger-update
โ”‚   โ””โ”€โ”€ bugfix/JIRA-203-email-template-fix
โ””โ”€โ”€ hotfix/JIRA-204-critical-prod-fix

main โ€” Reflects exactly what's in production. Never commit directly.

release/[version] โ€” Accumulation branch for the next release.

feature/[ticket-id]-[description] โ€” One branch per work item. Short-lived.

hotfix/[ticket-id] โ€” Emergency fixes that go directly to production.

The PR Gate

Every merge must include: code review, automated CI check passing, and no merge conflicts.


The Salesforce Metadata Model

force-app/
โ””โ”€โ”€ main/
    โ””โ”€โ”€ default/
        โ”œโ”€โ”€ classes/
        โ”œโ”€โ”€ triggers/
        โ”œโ”€โ”€ lwc/
        โ”œโ”€โ”€ flows/
        โ”œโ”€โ”€ objects/
        โ””โ”€โ”€ permissionsets/
# Retrieve all metadata
sf project retrieve start --target-org MySandbox

# Deploy to a target org
sf project deploy start --target-org Staging --test-level RunAllTestsInOrg

# Validate without deploying
sf project deploy start --target-org Production --check-only --test-level RunAllTestsInOrg

Setting Up a Basic CI/CD Pipeline (GitHub Actions)

name: Salesforce CI Validation

on:
  pull_request:
    branches: [release/*, main]

jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

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

      - name: Authenticate to Staging Org
        run: |
          echo "${{ secrets.SF_AUTH_URL }}" | sf org login sfdx-url \
            --sfdx-url-file /dev/stdin \
            --alias StagingOrg

      - name: Validate Deployment
        run: |
          sf project deploy start \
            --target-org StagingOrg \
            --check-only \
            --test-level RunAllTestsInOrg \
            --wait 30

Copado: Enterprise Salesforce CI/CD

Copado is the market-leading CI/CD platform purpose-built for Salesforce. It's native โ€” it runs inside your Salesforce org.

What Copado Does: Pipeline Management, User Story Tracking, Automated Testing, Back-Promotion, Compliance & Audit, Conflict Resolution.

Limitations: Expensive enterprise pricing, complex to configure initially, best for teams of 5+ developers.


Gearset: The Developer-Friendly Alternative

Gearset connects to both your Salesforce orgs and your Git repository from a web interface. Faster to set up and more intuitive.

What Gearset Does: Compare & Deploy, Automated Testing, Pipeline Automation, One-Click Rollback, Change Monitoring, Metadata Health checks.


Deployment Best Practices

Before Every Deployment

  • โœ… All Apex tests pass locally
  • โœ… Metadata reviewed by a second developer
  • โœ… Deployment plan documented
  • โœ… Rollback plan documented
  • โœ… Deploy to a full sandbox first

During Deployment

  • โœ… Deploy during low-traffic hours
  • โœ… Have the rollback plan ready
  • โœ… Monitor the deployment log in real time
  • โœ… Do not deploy on Fridays ๐Ÿ˜‚

After Deployment

  • โœ… Smoke test all critical paths
  • โœ… Verify integrations are functioning
  • โœ… Check error logs
  • โœ… Confirm test coverage didn't drop

Summary

CI/CD transforms Salesforce deployments from "white-knuckle events" into routine, reliable operations:

  • Branching strategy: main โ†’ release โ†’ feature branches, all changes via PR
  • CI pipeline: Automated validation on every PR
  • CD pipeline: Automated deployment after approval
  • Tools: Copado for enterprise, Gearset for mid-size teams, SFDX + GitHub Actions for lean teams

Want help setting up CI/CD? Book a consultation with ApexSensei. Start practicing on ApexSensei โ†’

Are you still using Change Sets? Tell me where your team is in the comments. ๐Ÿ’ฌ

Practice Apex free on ApexSensei