Force.com Migration Tool is Java ANT based command line tool to deploy metadata components from one Salesforce org to another org or deploy same metadata components to multiple Salesforce org's like Developer org -> UAT org -> Pre-Production org -> Production org. It allows you to deploy metadata components likes Objects, Communities, Apex classes, Apex triggers, Lightning Components and Visualforce Pages, and so on. The advantage of using Force.com Migration Tool is, it allows you to schedule a deployment over the weekend or non-business hours. This use Metadata API to deploy the components. It is very useful and time-saving to use Force.com Migration Tool in following scenarios
Before installing Force.com Migration Tool you need the following to be available and installed on your machine:
Java –version
Make sure that the output should look something like the preceding screenshot.
ANT_HOME
and JAVA_HOME. Set ANT_HOME
environment variable value to pointing to the directory where you have installed ANT. Set JAVA_HOME
environment variable value to pointing to the location of your JDK. On a Mac, it should look like the following screenshot:
To verify that you have properly installed and setup environment variables for Ant, run the following command on Mac Terminal or Windows command line:
ant –version
Make sure that the output should look something like the preceding screenshot.
Perform the following steps to install Force.com Migration Tool
Readme.html
contains the instructions how to use Force.com Migration Tool.Ant-salesforce.jar
is a JAR file containing the ANT task.codepkg
folder contains sample Apex class and Apex trigger.mypkg
folder contains sample custom object.removecodepkg
folder that contains XML files for removing the preceding metadata components from your org if deployed.build.properties
file is used to store your Salesforce credentials, to run the task.build.xml
file, that used to deploy and retrieve API calls.Force.com Migration Tool allows you to manage version control and keep a backup of your work on your local machine. It also allows you to create folders based on your project or deployment strategy.
A business scenario: David Guzman is working as System Administrator at Universal Containers. In Chapter 7, Optimizing Business Processes with Visual Workflow and Approval Processes he has created a custom field on Account
object called as Status__c
. Now he wants to migrate this field to his personal developer org using Force.com Migration Tool.
Perform the following steps to deploy metadata components using Force.com Migration Tool
UAT-Metadata
and Version 1
inside UAT-Metadata
. Then copy build.properties
and build.xml
files inside UAT-Metadata
folder, as shown in the following screenshot:
build.properties
file and enter Salesforce credentials
for source org to retrieve the metadata components based on the schema defined inside the package.xml
(we will create package.xml
in next step):
package.xml
file that contains account's custom field Status__c
. Either you can create it manually with the help of Metadata API developers guide or use Force.com IDE to do so. Once you have the package.xml
file moves it to inside the Version 1
folder. Then it should look something like the following screenshot:
Your package.xml
should look like the following screenshot:
build.xml
file and set the package.xml
location, inside target retrieveUnpackaged
tag, as shown in the following screenshot:
package.xml
: ant “retrieveUnpackaged”
If the retrieval or build is successful, then you will get success message on the screen. It should look like something the preceding screenshot. The next step is to navigate to UAT-Metadata
folder on your local machine. After successful retrieval of metadata components from source org, it should contain a folder object
inside retrieveUnpackaged
folder, as shown in the following screenshot:
Inside object
folder, you can find the document Account.Object
that contains complete schema of account's custom field Status__c
:
UAT-Metadata
folder on your local machine and edit the build.properties
file to change the Salesforce credentials pointing to target org.UAT-Metadata
folder. Then run the following command on Mac Terminal or Windows command line to deploy metadata components to target Salesforce org ant “deployUnpackaged”
:
If the deployment is successful, then you will get success message on the screen. It should look like something the preceding screenshot.
Design the folder structure as your want. Make sure to update the folder structure in build.xml
file.
18.118.16.229