Deploying Code

The Ant Migration Tool is retired with Spring ’24. The tool continues to function as-is for future API versions but isn’t updated with new functionality and isn’t supported.  If Salesforce adds a new feature that is incompatible with Ant, the Ant Migration Tool won't be updated to support it. To manage metadata changes, switch to Salesforce CLI for a modern, supported developer experience.

Note

You can deploy metadata components and Apex at the same time, but you may find it useful to create separate targets for deploying Apex, so that you can run tests as part of the deployment. A portion of a build.xml file is listed below, with a target named deployCode that deploys the contents of the codepkg package and runs the tests for one class.

1<target name="deployCode">
2  <sf:deploy 
3      username="${sf.username}"
4      password="${sf.password}"
5      sessionId="${sf.sessionId}"
6      serverurl="${sf.serverurl}"
7      deployroot="codepkg">
8    <runTest>SampleDeployClass</runTest>
9  </sf:deploy>
10</target>