One of the things I really like about Salesforce is that there is always something new to learn. This week, I needed to use a new tool called the Force Migration Tool (also known as ANT) for the first time. Even though the tool itself is not new, I was really impressed by it. In this blog post, I will try to explain what ANT is, why you need to know about it and how to get your hands on it.
What is ANT?
ANT is a tool to help you move Metadata (information such as Objects/Reports/Apex Classes/Visualforce Pages) between different Salesforce environments. Once configured, ANT allows you to easily move configuration from one Salesforce environment to another with a series of simple text commands that you enter into a Terminal window on your computer.
Why do you need to know about ANT?
1. You need a flexible way to deploy changes to multiple Salesforce environments at any one time (more on that below).
2.You want to start creating Salesforce configuration on your local computer using a text editor such as Sublime Text. If you are already using Eclipse this post talks about the difference between ANT, Maven, and Eclipse.
3. You are working with a team who are already using ANT.
Keeping it all in Sync
Let’s start with the biggest advantage that ANT offers.
Imagine that you have 2 different members of your team building some ‘cool new stuff’ in their respective development environments. At some point, both of these developers will need to put this new functionality into your testing and live environments.
If each developer worked independently, you may not know whether their work will be compatible with the other. ANT helps with this by giving you a powerful way to keep 2 (or more) Salesforce Orgs synchronised throughout your development process.
Regularly comparing and synchronizing your new development work helps to ensure that any incompatibilities are found much earlier on in your process. This technique is known as ‘Continuous Integration’.
What about Change sets?
Salesforce gives you a declarative tool to move configuration from a Salesforce Sandbox (test) environment through to another Sandbox or your Production environment.
The change set tool is very straightforward, however, items need to be added one by one, it is easy to miss components, and change sets can only be sent between orgs that are affiliated with your production org. For example, you can only deploy a change set from a production org and its sandbox, or two sandboxes created from the same org can send or receive change sets.
ANT can deploy configuration from one Salesforce environment to a completely unrelated second environment.
What about a Package?
A Salesforce developer can also package up changes to an unmanaged package. This would allow you to take some code from Salesforce Environment 1 and deploy it to an unrelated Salesforce Environment 2.
However, packaging has limitations. You again need to manually create the package, adding in components one step at a time. You then need to upload the package to Salesforce. You then have to wait whilst that package synchronises across all of the Salesforce servers/nodes.
Finally, once it has done that you can install the package in your new environment, bringing across the new configuration.
How do I get ANT?
If the flexibility of being able to move your Salesforce configuration between environments quickly and via a single command via your terminal has piqued your interest, have a go at setting up ANT and see if you can move a single item of your choice from environment A to environment B.