Salesforce Ant Migration

Ant Migration tool is used to Create and Fetch Metadata to and from an organisation.  It’s a  command-line utility by which one can upload and download Metadata components.


  1. Its very useful for creating repetitive deployment or may be a large number of components just by executing a command in an command line interface.
  2. Useful for uploading test environment with a lot of configuration settings.
  3. Manually creating Fields, Objects may take a huge amount of time when you create them by clicking with the salesforce interface. These fields can be created with one command in the Command line interface and using Package.xml file in which you specify the information about all the fields.
  4. The Name of the components we can Deploy or retrieve are as follows:
    1. Custom Fields.
    2. Objects.
    3. Workflow rules.
    4. Apex Triggers.
    5. Apex Class.
    6. Visualforce Pages. Etc.

The Whole list is mentioned in this link:


  1. Download migration tool from your salesforce organization.
    1. Go to Setup.
    2. Type “Tool” and Click on Migration tool & Toolkits.
    3. Go to the Following Link for downloading Ant:

  1. Add the bin directory to your path.
  2. Set the ANT_HOME environment variable to the directory where you installed Ant.
  3. Set the JAVA_HOME environment variable to the directory where the JDK is installed.
  4. Run command in Command-line Interface:   “ant -version” to check the version and confirm the installation.



  1. Create three Files:
    1. Package.xml – Which consists the specifications for the components.


<?xml version=”1.0″ encoding=”UTF-8″?>

<Package xmlns=””>






</Package> – Which consists the Credentials of the salesforce Organisation to & from which you want to Upload/Download.

sf.usernameDownload =

sf.passwordDownload = Password122


sf.usernameUpload =

sf.passwordUpload = aasfde@12131QV4cWJnmdflgBRdXsWznzohG

sf.serverurlDownload =

sf.serverurlUpload =

sf.maxPoll = 100

Note: You have to mention Security token at the end of the password of the Org in which you want to Upload the metadata.

         3.Build.xml – This file is used to set the attributes which will be used in the Command line interface such as “Project Name”,”Property File”,”retrieveTarget folder( where Downloaded metadata info will be saved)”,”unpackaged(Package.xml file)”.


<project name=”ANT Migration” default=”test” basedir=”.” xmlns:sf=”antlib:com.salesforce”>


<property file=”” />

<property environment=”env” />

<target name=”retrieve”>

<mkdir dir=”Retrieve” />







pollWaitMillis=”10000″ maxPoll=”100″ />


<target name=”upload”>







pollWaitMillis=”10000″ maxPoll=”100″ />



  1. Go to the path where you stored these files and then Run commands as follows:
    1. Upload(Which you mentioned in your build.xml file as target) – For uploading components you mentioned in the Package.xml file.
    2. Retrieve– For downloading the Components information you mentioned in the package.xml file and then that information will be created in a folder(Self Generated folder Named as Retrieve).

Author: AJ

Share This Post On


  1. Thanks Ajay
    This is the Life Saver for me, I just needed the information on ANT Migration tool and this blog helped me a lot


    Post a Reply
  2. Really help me to clear my concept over Ant tool

    Bhupinder Mankotia

    Post a Reply

Submit a Comment

Your email address will not be published.

× How can I help you?