The development of applications on Force.com platform can be easy, fun and very productive. The developer can combine elements in an architecture composed of custom fields, apex classes, visualforce pages, workflow rules and all the metadata types offered by the platform. Depending on the development lifecycle, the software can be staged in different sandboxes for testing purposes, quality assurance controls and finally it will be deployed to the production environment. In a deployment strategy only based on change sets, three main capabilities are not fully satisfied:

  • Merging
  • Branching
  • Data Recovery

The following guide aims at showing how to build a deployment strategy in a Salesforce environment that ensures a better coverage of the three areas mentioned above using Subversion as software for versioning and revision control. In the struggle between SVN and GIT the sentence “Nobody uses Subversion anymore” is just a myth, in fact many companies continue using this tool because it represents the standard enterprise version control system.

Following the tools that must be enabled and configured in order to reach our goal.

Java

Java version 1.7.x or later is recommended for better security and for the latest TLS protocols. Check the version of Java installed on your system:

  • Open a command prompt.
  • Type java -version and press Enter.

The output looks like the following if you have Java version 7:

  • java version “1.7.0_21”
  • Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
  • Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)

If java VM is not installed you can download it here.

Ant

Execute the following steps to check the installed version of ANT:

  • Open a command prompt
  • Type ant -version and press Enter

If the Ant version is 1.5.x or earlier, you will need to download the latest version of Ant (link here). Even if you have Ant installed, you may still need to put the bin directory on your path. On a Windows operating system, you may also need to set the ANT_HOME and JAVA_HOME environment variables as follows:

  • ANT_HOME : C:\Program Files\apache-ant-1.9.7
  • JAVA_HOME: C:\Program Files (x86)\Java\jre1.8.0_91

Be also sure to add the following parameters “%JAVA_HOME%\bin;%ANT_HOME%\bin;” to the PATH variable.

Eclipse

Download the latest version of Eclipse IDE (link here). Be sure to choose the right one based on your operating system characteristics (32 bit/64 bit). After Eclipse installation you need to install two additional plugins, click on “Help” – “Install New Software” and insert the following plugin repository links in the “Work with” section:

  • Subversive – SVN Team Provider (link repository: http://download.eclipse.org/technology/subversive/4.0/update-site/): this plugin lets you interact with SVN folders. In a continuous integrated scenario, the developer starts updating the local eclipse project with SVN metadata and only at the end of the development phase he executes the commit in the svn repository
  • Force.com IDE (link repository: https://developer.salesforce.com/media/force-ide/eclipse45): this plugin lets you interact with the Salesforce sandboxes directly. In a continuous integrated scenario, the developer uses the IDE to deploy to his own developer sandbox for local testing purposes before committing in the main svn repository

Before going further you also need to configure Eclipse for working with SVN ant. Download the latest stable build at the following link. Once installed, extract the jar files listed below:

  • svnant.jar
  • svnClientAdapter.jar
  • svnjavahl.jar

Place them in your workspace directory and execute the following steps in order to load them at runtime:

  1. Open Eclipse
  2. Window > Preferences
  3. Ant > Runtime
  4. Ant Home Entries (Default)
  5. Click Add External JARs
  6. Navigate to your workspace
  7. Select the 3 .jar files
  8. Open > Apply > OK
  9. Restart Eclipse

Force.com Migration Tool

Intro & Installation

Download the latest version of Force.com Migration Tool (link here) to automate deployments from different sources to different destinations. In particular, you can use the migration tool to execute deployments in two different ways:

  • Salesforce To Salesforce: a Salesforce sandbox is the origin and another Salesforce sandbox is the destination
  • SVN To Salesforce: SVN metadata folder is the origin and a Salesforce sandbox is the destination

Configuration

Three main files must be configured in order to get the job done and to run the Force.com Migration Tool correctly:

1. build.xml
The following snippet of code represents a sample configuration of the build.xml file. In particular, it contains the definition of an ant task that can be run from the Eclipse console:

Target tag defines the ant tasks visible in the Eclipse console. In particular, the example shown above contains two main tasks:

  • deployToMergeFromSVN (Salesforce to Salesforce deploy): this task executes a full download of the svn folder metadata tree and it performs a deploy into a merged sandbox environment
  • deployToTestFromMerge (SVN To Salesforce deploy): this task performs a deploy of the metadata stored in the local folder, defined by the deployRoot attribute

2. package.xml
This file contains the list of Salesforce metadata that must be deployed by the automatic procedure categorized by metadata type. Only the mapped elements will be deployed, the unmapped ones will be discarded. A sample configuration of this file is displayed below:

The tag members contains the name of the resource, specifying the * wildcard all the metadata of that specific type will be included in the deploy activity.

3. build.properties
The following snippet of code represents a sample configuration of the build.properties file. In particular, it contains the definition of all the variables used by tasks defined in the build.xml file:

Finally, you need to show your ant tasks (configured in the build.xml) in the Eclipse console. This requires you to follow the following steps:

  1. Window > Show View > Ant
  2. Add JAR Buildfile

Now the list of the ant tasks is displayed and you can easily run one of them by clicking on its name and following its execution on the log console.

Support us with a small donation:

  • LTC Address: La5f6W1rPr5VHFGCrCmPJ3sSa2AiwKZJbU
  • BTC Address: 1FG1j42MUze8jiW7JbgNaUMZxZeu7M1b4f
  • Ripple Address: rPVMhWBsfF9iMXYj3aAzJVkPDTFNSyWdKy     Tag: 562614972
  • ETH Address: 0x0940958167ca9cbd6409999957a011be7907d904
(Visited 2,023 times, 3 visits today)
Emanuele Campisi
Emanuele Campisi

Emanuele has more than 5 years of consulting experience, primarily focused on CRM platforms and mobile apps he is convinced that “each new piece of information might yield an insight that helps solve a problem or create a breakthrough”.

Leave a Comment