Salesforce Deployment using Ant Migration Tool
Salesforce offers a few options to deploy config and code between sandboxes and into production. Most commonly used is the standard inbuilt changeset option, allowing a user to select the exact components they wish to deploy and use the Salesforce interface to manage and perform the deployment.
There are times however when changesets can be a little ineffective, especially when needing to select and deploy a large set of components or the need to perform repeated deployments. In these circumstances it may be better to use the Ant Migration Tool to perform the deployment.
Steps to using the Ant Migration Tool are listed below:
Step 1 - Download the Force.com Migration tool. A direct link to the zip file can be found here.
Step 2 - Save the zip file and extract it to a local folder on your hard disk.
Step 3 - Navigate to the /samples directory within the zip file.
Step 4 - Open the build.properties file and setup your username and password for your source and target environments.
Step 5 - Open the build.xml file and define the operations that you wish to conduct. In this example I have defined two operations:
retrieveIntegrationFiles - this operation logs into my development sandbox and downloads the specified files into the /samples/mypkg folder.
- retreiveTarget parameter specifies the folder in which the contents will be downloaded
- unpackaged parameter specifies the location of package.xml file which defines the contents to be downloaded
deployCodeNoTestLevelSpecified - this operation logs into my QA sandbox and performs a deployment without running any tests.
- deployRoot parameter specifies the root folder containing the files/package to be deployed including the package.xml file
- deploy command performs a deployment without running any tests - this is only applicable to sandboxes
Step 6 - Create a package.xml file in the mypkg folder which specifies the items you wish to download and/or deploy.
Useful Guides
For a guide on what metadata types the package.xml file can be used for, please click here.
Salesforce also provides a guide with sample package.xml files, which you can use to see the ways in which this file can be constructed.
Step 7 - Open the terminal and navigate to the /samples folder.
Step 8 - Run the following command: ant retrieveIntegrationFiles
Step 9 - You will notice that the contents will be downloaded to the mypkg folder.
Step 10 - To deploy your code to your target environment execute the following command: ant deployCodeNoTestLevelSpecified
Step 11 - Monitor for any errors, update the package.xml file for missing dependencies and perform a retrieve and deploy again if there are any components missing.
Step 12 - Relax and enjoy, you have discovered a new means to perform deployments in Salesforce.com
Comments
Post a Comment