Saturday, May 2, 2020

Salesforce ANT Deployment – Retrieve |Validate | Deploy


Setup the ANT into your system properly before going to use it. Please check here the ANT setup guide if you haven’t done it so far

Understanding build.xml | build.properties | package.xml

build.properties – you must update this file to specify the salesforce org credential in order to complete the ANT task in build.xml

build.xml – you must modify the build.xml file to indicate the location of ant-salesforce.jar file. Modify the path the of the ant-salesforce.jar in location attribute of <pathelement> in build.xml.


Package.xml – you need to update the metadata component in this xml file. package.xml is a collection of metadata components which are identifies by the programming interface.
Here are the steps that need to follow to retrieve code from source org and deploy the code in Target org-

Step#1
Update the build.properties file with source org credential and server url. For non-production org server url would be test.salesforce.com

Step#2
Modify the package.xml with the necessary component which needs to be deployed from source org to Target org.
Here we are going to deploy one Apex class (OrderHelper) and one Apex Trigger (OrderTrigger) to understand the process-


Step#3
Run the command ant retrieveCode in command prompt to retrieve the code from source org to local machine.

retrieveTarget=”codepkg” – This attribute indicates that the component mentioned in the package.xml will be retrieve to codepkg folder.




Step#4
As of now we have retrieved the component from Source org to local machine. Now we are going to push the same components to production.
Update the credential in build.properties with server url. To deploy into the production change the server url to Login.salesforce.com
Make sure that you have included the necessary test class in the package.xml within the <runTest></runTest> tag under <target name=”deployCode”> element.
testLevel=RunSpecifiedTests indicates that the command will run only specific test classes that are mentioned within <runTest> tag.


Step#5
Run the command ant deployCode .
To validate the component with test coverage use checkOnly attribute.
checkOnly=true indicates that the command will only validate with test class coverage (Similar to validate change set with run as specific test class)
checkOnly=false indicates that the command will validate and deploy the component to Target org.
You can also check the validation status in salesforce- Setup->Deploy->Deployment Status



Step#6
Now its time to Quick Deploy!
Copy the Request Id from command prompt and paste it in build.properties file as recentValidationId.


Now Run the ant quickDeploy command to deploy the recently validated components.



Congratulations! You have completed deployment using ANT deployment tool

2 comments:

  1. very helpful article. thanks for sharing this.

    ReplyDelete
  2. However, in our checks it printed just one great-looking model, along with six okay-looking fashions and one failure. We favored the printer’s streamlined software, which made it straightforward for us to select out} what elements of a model to make which shade. You load fashions onto the Sweaters printer with an SD card, so queuing up quantity of} prints at a time is also be|can be} straightforward, and it has a large, 8.9-by-5.8-by-5.9-inch print volume. In our checks, the preliminary calibration was a barely extra guide course of than for our other picks, because the Sidewinder X2 has a Level menu that moves the extruder to preloaded points across the print bed. It takes a bit of expertise to dial on this course of, but the Sidewinder X2 makes it easier and quicker than most other manually leveled printers do. Printers with bigger beds are all the time harder to degree, since a bigger area is extra prone to warping or slight imperfections.

    ReplyDelete