Using Jenkins and Git for Metadata backups and running Test Cases

Posted by Johan on Sunday, September 3, 2017

One thing that makes Salesforce great is the possibility to use it and customize it quite far without having to invite developers. I can see the beauty of this since developers are expensive and slow, before you think about writing a comment on that last statement keep in mind I’m a developer myself. One thing that code developers (as opposed to click developers) bring to the table is source control. This is mostly because anyone who has ever written a piece of code bigger than “hello world” knows that it’s super hard to get code right the first time, or the second time, and so on.

Coming from the coding part of the world developers love source control, code reviews, continuous integration and so on. For a Salesforce using company without an in house development team this is usually not something they ever think about.

Before I continue my rambling, my point is that Source Control is something anyone can benefit from, especially since the Metadata API in Salesforce makes it very easy to retrieve everything via the API.

I have created a small GitHub project here. If you have a Jenkins instance to spare you should be up and running within the hour taking a backup of your Metadata and also running your test cases (if you have any Apex code) to make sure a declarative change didn’t break your test cases, which you would find out about the next time you’re trying to deploy something in your very tight 1 hour service window (yes that will happen).

In short, clone the GitHub project and follow the README. If you don’t have a Jenkins instance you can easily find one here. I had an old VMWare server where I just deployed their VMWare image.

Having regular Metadata backups is great, especially if you have more than 1 Salesforce Administrator. It might not help you in a proactive way but you’ll get a full audit trail on when a Profile was changed or when a column in a List View disappeared.

If you run into any problems, just let me know and I’ll be happy to assist you, no one should run their Salesforce instance without regular backups.

I used this GitHub project as a starting point, big thanks to @JitendraZaa for doing most of the heavy lifting.

Cheers, Johan