All Collections
Feature guides
Automation and CI
Continuous integration
How to spin up Salesforce scratch orgs from CI jobs
How to spin up Salesforce scratch orgs from CI jobs

Deploy metadata from source control to a new scratch org with Gearset CI

Valerio Chang avatar
Written by Valerio Chang
Updated over a week ago

Scratch orgs are useful for running your Apex code and tests in an environment that's realistic and clean, and testing that your deployments will work using an org that isn’t critical and can be forgotten about.

When adding a new continuous integration (CI) deployment job in Gearset, you can now select scratch org as the target.

There are a few requirements to creating a new scratch org as your target:

  • A source control repository (e.g. GitHub or Bitbucket) is connected and selected as the source type.

  • A Dev Hub-enabled org is connected in Gearset. (More information about setting up Dev Hubs in Gearset can be found here.)

  • A scratch org definition file ending in scratch-def.json is included in the /config folder or root of your source repository.

After selecting scratch org as the target type, your Dev Hub will already be selected in the ‘Dev Hub’ field if only one is connected to Gearset. If you have more than one, you can choose from the dropdown.

Gearset will look for a scratch org definition file ending in scratch-def.json in either a /config folder or the root of your source Git repo. Here are some of the options you can configure for your scratch org:

  • Org name

  • Description

  • Features

  • Settings

More information about scratch org definition files can be found in the Salesforce DX Developer Guide here.

After you’ve finished configuring and saving your CI job, it will run on its specified schedule.

Did this answer your question?