Here is the official documentation from Salesforce - Click here.
In this article, I will try to provide steps to quickly setup the deployment process. For a detailed description of every file and various options please go through the link above. This article is only for a quick setup process and doesn't intend to cover details.
STEP 1:
Visit http://java.sun.com/javase/downloads/index.jsp and install Java JDK, Version 6.1 or greater on the deployment machine.
STEP 2:
Install the JDK. I have installed my JDK in the path below. Note that the folder name will begin with jdk, you might also see a folder which begins with jre
STEP 3:
Visit http://ant.apache.org/ and install Apache Ant, Version 1.6 or greater on the deployment machine.
STEP 4:
Unzip the Apache ANT file downloaded in STEP 2 into any desired folder. Let's assume we unzip the folder into the location as shown below.
I download and UnZipped Apache ANT into my C:/ . You can use any directory you wish.
STEP 5:
We will now setup the environment variables.
STEP 6:
Add the following two variables to the 'User Variables' and 'System Variables' .
ANT_HOME : C:\apache-ant-1.9.4-bin\apache-ant-1.9.4
JAVA_HOME : C:\Program Files\Java\jdk1.8.0_05
Append the two BIN paths to the 'Path' variables under both 'User Variables' and 'System Variables'. My Path variable looks like this.
Path: c:\Program Files\Intel\WiFi\bin\;c:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Java\jdk1.8.0_05\bin;C:\apache-ant-1.9.4-bin\apache-ant-1.9.4\bin;C:\Users\Edwin.Raymond\AppData\Roaming\npm
Note: These locations are based on the directories in which i installed JAVA and APACHE ANT. Your location might be different if you installed in a different directory. The Path variable should point to the BIN directory.
STEP 7:
Verify that the installations were successful by going to the command prompt and executing the following commands.
STEP 8:
Log in to Salesforce on
your deployment machine. From Setup, click Develop | Tools, then
click Force.com Migration Tool.
Unzip the file to a directory of your choice. I unzipped it to my desktop.
STEP 9:
Download the following folder from the location https://drive.google.com/file/d/0B5FQvDdE4z0PYmhIZGVMaXFVSVk/view?usp=sharing
Unzip the file to a directory of your choice. I unzipped it to my desktop.
STEP 10:
Replace the ant-salesforce.jar file from location in STEP 8 to the location in STEP 9 as shown below.
STEP 11:
Now, modify the build.properties file in the 'deploy_sf_ant' folder. This file contains the username/password for the sandbox and production organizations. Open build.properties with WordPad and enter the details.
STEP 12:
Place the package.xml in the 'RetrievePackage' folder. The package.xml file contains the list of components you want to deploy.
STEP 13:
Run the command 'ant retrieve' from the command prompt to retrieve the changes from sandbox. Make sure you run the command from the folder location specified like below. After you run the command, a folder named 'deploy' is created.
STEP 14:
Run the command 'ant deploy' from the command prompt to deploy yo changes to production.
STEP 15:
Use the instructions.txt file for subsequent deployments.
1. Place package.xml in the folder 'Retrieve Package'2. from CMD run 'ant retrieve'
3. Folder 'deploy' is created.
4. To validate change edit build.xml and make 'checkonly = true'.
5. To deploy make checkonly = 'false' and from CMD run 'ant deploy'
6. Rename the 'deploy' folder and copy to 'completed' folder for history tracking.
7. Delete the 'deploy' folder