How to retrieve your entire Salesforce metadata with 2 commands

One of the first steps in implementing CI/CD for Salesforce is storing your Salesforce metadata in a Git repository.

Recently I learned about a newish sfdx command that allows you to retrieve all the metadata in the org without having to know beforehand what metadata types you have, which fields to include, etc.

Thanks to Alba Rivas for this information, which was provided in this Developer Quick Take:

Steps

First, we'll run a command to generate a package.xml file that includes every single metadata item in your org

sfdx force source manifest create --fromorg [your org alias] --manifestname=allMetadata --outputdir manifest

Or if you are using the newer commands

sf project generate manifest --output-dir manifest --name=allMetadata --from-org [your org alias]

Once you run this command, you'll see allMetadata.xml file under the manifest directory:

You'll notice this file lists all the metadata in your org!

All your salesforce metadata in the XML file

The next step is very simple. All you have to do

is to right-click the file, and select "Retrieve source in manifest from Org"

And that's it! Now all your Salesforce metadata is in the sfdx project.

The next steps are uploading this to GitHub and configuring the pipeline. You can find steps for this in the following article:

Build Your Own CI/CD Pipeline in Salesforce (Using GitHub Actions) | Salesforce Ben
Learn how to create your own CI/CD pipeline (using GitHub actions) in Salesforce with this comprehensive tutorial.

Subscribe for exclusive Salesforce Engineering tips, expert DevOps content, and previews from my book 'Clean Apex Code' – by the creator of HappySoup.io!
fullstackdev@pro.com
Subscribe