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
No comments:
Post a Comment