• Home
  • Download
  • Documentation
    • Quick Start
    • Connections
    • CONFIGURE
    • SF ACTIONS
    • WORKSPACE ACTIONS
    • OPTIONS
    • HELP
    • RELEASE HISTORY
  • License
  • FAQ
    • FAQ
    • INSTALLATION WARNING
    • LICENSING
    • LOGGING INTO SALESFORCE
    • LARGE DATA SETS
    • STANDARD VS CUSTOM FIELDS
    • INSERTING PROFILES
    • SYSTEM PERMISSIONS
    • VERSIONS
    • ENHANCEMENTS
  • SF TIPS
    • SF TIPS
    • DEPLOYMENT COMPARISON
    • CONTINUOUS INTEGRATION
    • CHROME EXTENSIONS
    • VS CODE AND CLI
  • About Us
  • More
    • Home
    • Download
    • Documentation
      • Quick Start
      • Connections
      • CONFIGURE
      • SF ACTIONS
      • WORKSPACE ACTIONS
      • OPTIONS
      • HELP
      • RELEASE HISTORY
    • License
    • FAQ
      • FAQ
      • INSTALLATION WARNING
      • LICENSING
      • LOGGING INTO SALESFORCE
      • LARGE DATA SETS
      • STANDARD VS CUSTOM FIELDS
      • INSERTING PROFILES
      • SYSTEM PERMISSIONS
      • VERSIONS
      • ENHANCEMENTS
    • SF TIPS
      • SF TIPS
      • DEPLOYMENT COMPARISON
      • CONTINUOUS INTEGRATION
      • CHROME EXTENSIONS
      • VS CODE AND CLI
    • About Us
  • Home
  • Download
  • Documentation
    • Quick Start
    • Connections
    • CONFIGURE
    • SF ACTIONS
    • WORKSPACE ACTIONS
    • OPTIONS
    • HELP
    • RELEASE HISTORY
  • License
  • FAQ
    • FAQ
    • INSTALLATION WARNING
    • LICENSING
    • LOGGING INTO SALESFORCE
    • LARGE DATA SETS
    • STANDARD VS CUSTOM FIELDS
    • INSERTING PROFILES
    • SYSTEM PERMISSIONS
    • VERSIONS
    • ENHANCEMENTS
  • SF TIPS
    • SF TIPS
    • DEPLOYMENT COMPARISON
    • CONTINUOUS INTEGRATION
    • CHROME EXTENSIONS
    • VS CODE AND CLI
  • About Us
Security Zen

Salesforce Deployment Comparison

Salesforce Deployments

Security Zen is great for managing security, but what about analyzing and deploying the rest of your metadata?  If you are familiar with the Force.com Migration Tool, there is a simple addition you can make that provides great  insight into the details of your deployments.

1. Install Force.com Migration Tool

Force.com Migration Tool has some pre-requisites such as Java and Ant and then you have to install the Force.com Migration tool itself.  This process can be a little painful, but you only have to do it once and I promise it is worth the effort.  Details can be found here.

2. Customize Force.com Migration Tool

For each environment, add a "retrieve" command in your build.xml file along with an appropriately named folder.  For example, for a DEV environment, you can add a command like the following that retrieves data into a "DEV_Compare" folder:


<target name="getDEVCompare">

<delete dir="DEV_Compare" />

<mkdir dir="DEV_Compare" />

<sf:retrieve 

   username="${dev.username}"

   password="${dev.password}"

   serverurl="${dev.serverurl}"

   retrieveTarget="DEV_Compare"

   unpackaged="DeploySource/package.xml"

/>

</target>


Note that the variables "${dev.XXXXXXX}" need to be defined in your build.properties file.


There also needs to be a package.xml file located in the DeploySource folder that defines what metadata will be compared/deployed.  Instructions for the building the package.xml file can be found here.


Repeat setting up a retrieve command for each environment that stores data into an appropriately named folder.

3. Install comparison tool

You can use any diff tool that has a command line interface and can perform folder comparisons.  I like KDiff3 because it does a nice three-way folder comparison.

4. Create a .bat file

Steps 1 and 2 are standard Force.com Migration tool, and step 3 is your favorite comparison tool, but now comes a little magic...


Create a text file with the extension .bat such as "Compare_DEV_STG_PRD.bat" and store it in the same directory as your build.xml file.


The contents of this bat file will have commands to retrieve the same metadata from each environment and automatically launch the comparison tool.  For example:


cmd /c ant getDEVCompare

cmd /c ant getSTGCompare

cmd /c ant getPRDCompare

"C:\Program Files\KDiff3\kdiff3.exe" ".\DEV_Compare" ".\STG_Compare" ".\PRD_Compare" --cs "UnfoldSubdirs=1" --cs "ShowLineNumbers=1" --cs "ShowIdenticalFiles=0" 


What does this do?

  • The first three lines are retrieving metadata from three different environments and the results get stored in separate folders.
  • The fourth line launches the comparison tool and does a folder comparison between these three folders.  This line assumes KDiff3 is installed in the default installation directory and also includes some options specific to KDiff3.

The payoff?  Whenever you want to compare/deploy metadata between environments, you can just populate your package.xml file and then double click the bat file.  You quickly get a detailed comparison showing which files have changes AND the details of the changes within these files.


Do it once and I guarantee you will use it before every deploy!


KDiff Sample GUI
SF TIPS

Copyright © 2017-2025 Security Zen - All Rights Reserved.


Cookie Policy

This website uses cookies. By continuing to use this site, you accept our use of cookies.

DeclineAccept & Close