Unlocking the Power of DevOps in Salesforce: A Comprehensive Guide
July 12, 2024
This article was written by Nate Nirubatharan, Technical Architect.
What is DevOps?
DevOps is a methodology or set of practices that combines software development (Dev) with IT operations (Ops). The goal of DevOps is to shorten the system development life cycle and provide continuous delivery of high-quality software. It prioritizes collaboration, automation, monitoring, and feedback loops between developers and IT operations teams.
Salesforce DevOps aligns with the broader definition. It emphasizes collaboration between admins and developers. Ensuring they can build, test and deploy changes effectively with minimal issues and maximum value to users.
What problems does DevOps solve?
Reduce Operation Overhead: Software development often involves long cycles with manual processes. DevOps enables a faster and more robust development life cycle leading to time and cost savings.
Automation: Safely automate as many processes as possible for increased efficiency and coordination. This includes activities such as testing, deployments and environment provisioning.
Error Prone Processes: Manually performing software development activities can be time consuming and prone to human error. DevOps flags errors early, minimizes bugs and frees up time for more strategic work.
Scale: Scaling software systems for changing demands can be complex. DevOps enables organizations to scale for growth dynamically and efficiently.
Challenges with DevOps in Salesforce
The Salesforce ecosystem has been slower to adopt robust DevOps practices compared to traditional software development. This is largely due to the fact that DevOps has historically focused more on conventional coding whereas Salesforce is platform-based and typically involves a lot of declarative (ie. drag and drop) configurations.
Version Control for Configuration: Managing changes to Salesforce configurations (such as custom objects, page layouts and flows) in version control systems can present challenges due to the nature of the underlying metadata files and dependencies involved.
Limited Tooling Ecosystem: Tools such as Salesforce DX and the Metadata API allow for more traditional software development and deployment. However the ecosystem for DevOps in Salesforce is still evolving. Reconciling CI/CD pipelines, version control systems and testing frameworks with Salesforce configurations, integrations and environments may be a challenge.
User Adoption: Introducing DevOps practices with Salesforce may require changes to existing processes. Training in the tools and tasks necessary to facilitate DevOps in Salesforce will likely be needed. Change management and ensuring buy-in from all teams may be difficult.
How should DevOps be used in Salesforce?
Version Control System (VCS): A software tool that tracks changes to files and directories over time, enabling multiple contributors to collaborate on a project, keep track of changes, and manage different versions of the project's codebase or files.
Salesforce implementation projects will often use the production org as the source of truth. Using version control as the single source of truth along with a VCS platform like GitHub will promote collaboration, transparency and history tracking.
Continuous Integration & Continuous Deployment: Practices used in software development and DevOps to automate and streamline the process of delivering code/configuration changes to production environments.
Continuous Integration (CI): A development practice where developers regularly integrate their code changes into a shared repository, such as a version control system on a regular basis. Each integration triggers automated build and testing processes to validate the changes. The goal of CI is to detect and address errors early in the development cycle, ensuring that the codebase remains stable and ready for deployment at all times.
Continuous Deployment (CD): An extension of CI that automates the deployment of code changes to specific environments after they have passed through the CI process. With continuous deployment, every successful build and test in the CI pipeline results in the automatic deployment of the changes to a different environment, without manual intervention. The goal of CD is to deliver new features, bug fixes, and updates to users rapidly and reliably, reducing lead time and increasing the frequency of deployments.
The native Salesforce deployment tool is Change Sets. The process involves manually selecting code or configuration changes to move between environments. They have a few important drawbacks when compared to CI/CD processes:
Components have to be added manually making it time consuming and error prone.
Packages need to be cloned and manually pushed each time to a different environment.
Not all components are supported (ex. some standard picklist values).
There is no rollback mechanism.
Cannot be integrated with version control system.
Environment and Branching Strategies
Environment management is important for any Salesforce implementation project. It becomes even more crucial to determine the right environment structure when using DevOps tools like VCS and CI/CD. There is complexity in managing Salesforce environments and version control branches together cohesively.
In version control systems, a branch is a distinct set of code/configuration changes. It may represent the master (production code), a specific feature, release, hotfix, etc. Branching strategies define how branches are created, managed and merged within the version control repository. When combined with CI/CD, it also determines how code/configuration is pushed across environments.
Determine the right environment strategy. This will factor the organization’s development process, team structure, project requirements and budget constraints.
Have the ability to quickly create development environments on demand. It should contain all the metadata necessary to develop a feature. Leveraging Salesforce DX and scratch orgs is ideal for this.
Establish a pipeline to production. At a minimum, a development and production environment are necessary. Depending on the project requirements, it is recommended to also include integration, staging and UAT environments. This allows for end-to-end testing, release preparation and training.
Determine which sandbox type to use for each environment. Ex. Full Copy sandbox for staging. Full or Partial Copy for UAT. Developer, Developer Pro or scratch orgs for development.
One template for an environment/branching strategy involves using individual Developer sandboxes, one testing sandbox and production. Each environment has a corresponding branch in VCS. In this example git is used as the VCS with a custom CI/CD build using Jenkins.
Testing Automation: Automating tests is a standard practice in DevOps and CI/CD processes. Salesforce has built-in testing capabilities including the running of tests during deployments and a mandated minimum code coverage to pass. Third-party testing tools/frameworks for further automating different types of tests in Salesforce are available. For example, Provar is a Salesforce specific end-to-end testing tool. UI testing tools like Selenium or performance testing with tools like JMeter can also be added.
Code Scanning: A robust code review process helps ensure quality and adherence to standards for software. While it shouldn’t entirely replace a manual code review, using code scanning tools can flag issues before a pull request/manual review and save time. Some examples of code scanning tools for Salesforce include CodeScan, Quality Clouds and Clayton.
Backups: Another integral part of DevOps is backing up data and metadata.
Data Backup: Salesforce provides an add-on in the form of a package called Salesforce Backup. It helps prevent data loss and corruption, recover data quickly and simplify the overall data management strategy. Alternatively, third-party tools are also available.
Metadata Backup: Salesforce does not have metadata backup features by default. A third-party tool such as Spanning Backup or Gearset can be used. Version control tracks a history of revisions to the source. This can be used to revert back to previous states if desired.
Options for DevOps Tools in Salesforce
Salesforce DevOps Center: DevOps Center is an app provided directly by Salesforce to connect to VCS and manage a CI/CD pipeline all within the Salesforce platform.
Third-Party Tools: External tools like Copado or Gearset can be used to connect with Salesforce and facilitate DevOps processes.
Custom: Open source CI/CD services like Jenkins or CumulusCI allow you to create your own DevOps automations.
DevOps in Salesforce may seem daunting and complex. But with the right analysis and adoption of DevOps practices and tools, Salesforce implementations can be optimized. Embrace DevOps and your organization can accelerate its delivery, improve quality, enhance collaboration, expand scalability and ultimately provide better customer satisfaction.
About the Organization
Belmar Consulting is an award-winning Salesforce implementation partner, who works with various organizations and enables them to succeed in their digital transformation journey. We combine our intimate knowledge of the public sector and the nonprofit industry with Salesforce to create and implement innovative solutions for our clients. Belmar’s dedication to delivering successful client projects means our clients are more effective in their role to fulfill their organizational missions.