Introduction to Salesforce Scratch Org Pools

Diéffrei Quadros
3 min readFeb 24, 2023

--

Photo by Denys Nevozhai on Unsplash

As described in my previous post, scratch orgs are one of the greatest resources for modern salesforce development; however, provisioning it requires some effort as I described in my previous post.

Scratch Orgs are great! However, when you create a scratch org it comes “empty”, there is only standard functionality that can be configured via features and settings beforehand using a scratch org definition file.
Usually, to have a scratch org ready for use, these are some typical steps:

  • Create a scratch org definition file or use a scratch org shape.
  • Install package dependencies
  • Deploy metadata (which also could include, or replace some metadata based on environment configuration, e.g endpoints, integration users, etc…)
  • User configurations (Permission Set Assignments)
  • Data imports for record-based configurations and test data

If you add all those steps in a timeline you will see that every step takes a considerable time.

Just in case you missed it, the drawbacks of allowing developers to create their own environment on their local machine are described in my latest post.

Sandbox vs Scratch org creation time

As I mentioned earlier, scratch orgs offer numerous benefits over sandboxes.
Although, with great power comes great responsibility!
Scratch orgs require you to prepare them, and it takes time.

For some large projects, a sandbox can take around two hours to get ready. In contrast, a scratch org could take even more depending on code and dependencies.

Scratch Org Pools

To overcome the slowness of scratch org preparation, you can use
Scratch Org Pools!

Pools are designed to provide a ready-to-use set of scratch orgs for developers and continuous integration. By maintaining a pool of scratch orgs, teams can instantly access the resources they need, enabling them to work more efficiently and productively.

By leveraging scratch org pools, development teams can get new environments as needed, without having to wait for manual setup and configuration. This provides greater agility and flexibility for the team, enabling them to focus on developing and testing new features rather than spending time on administrative tasks.

Overall, scratch org pools are a valuable tool for any development team that wants to streamline their processes and optimize their workflows. By making it easier and faster to set up and manage scratch orgs, teams can improve their productivity.

Scratch org pools tooling

Scratch org pools are not a native platform feature, however, there are a few tools that can help, I will focus on the ones I already used:

Hutte (https://hutte.io/) — Web application that supports scratch org pools + a bunch of other features like scratch org sharing and pull request creation.
Very great tool, I suggest you take a look, especially if your team is a mix of devs and admins.

Dx@scale sfpowerscripts (https://dxatscale.io) — Open source tool, which is reshaping the way to develop in salesforce.
Scratch org pool is only one of the features that sfpowerscripts supports.
It has been used by many large initiatives backed by a strong community in which I have the pleasure to participate. Join us!

Provisioning scratch orgs at Scale

The first benefit of sfpowerscripts it is an open-source sfdx plugin that allows you to run on most Operational Systems.

Official templates are available for Gitlab, Github Actions, and Azure DevOps).
The documentation of sfpowerscripts is available here.

Process Overview

In a nutshell, the scratch org pool creation process is a scheduled pipeline, which runs the sfpowerscripts prepare command.
The prepare command is responsible to create and prepare scratch orgs and assign them to the pools.

Once scratch orgs are ready in the pool, they become available to get fetched using the command:

sfdx sfpowerscripts:pool:fetch --tag my-dev-pool --alias my-scratch-org

Very important — During this process sfpowerscripts will synchronize sfdx source-tracking information. This means that once you fetch scratch org, you are up and running to change code and push/pull to your brand new scratch org.

Demonstration

Final

Are you curious about how to set up sfpowerscripts and how to provision scratch orgs for your team?
Subscribe and don’t miss the next blog post about how to setup Scratch org pools using Dx@scale sfpowerscripts!

Special thanks to my opensource colleagues Azlam & Vu Ha for always reviewing and sharing feedback!

--

--