1
votes

I have a requirement where I need to deploy a managed package installed on my source org to the target org. I believe there must be a way to deploy the same using ANT like we do for all other Salesforce related components.

Can somebody help me point out the process and the ANT syntax which could be used in achieving this?

I first want to retrieve the package in my local then deploy the package to the target org.

1

1 Answers

0
votes

You can use ANT migration for managed packages too. Just use the "retrieveNamedPackage" target in the ANT command to pull a managed package.

In this "retrieveNamedPackage" target, you should specify the correct managed package name in the packageNames attribute.

<target name="retrieveNamedPackage">
<sf:retrieve 
  username="${sf.username}" 
  password="${sf.password}"
  sessionId="${sf.sessionId}" 
  serverurl="${sf.serverurl}" 
  retrieveTarget="projectFolder" 
  packageNames="mySourcePackage"/>
</target>

Reference For Retrieve: https://developer.salesforce.com/docs/atlas.en-us.daas.meta/daas/forcemigrationtool_retrieve_packaged.htm

After retrieval, the content would now be in "projectFolder" (as it is mentioned in the retrieveTarget attribute.

For deploying the contents from "projectFolder" (which is your managed package components) to a destination org, use the following target.

<target name="deployPackaged">
<sf:deploy 
  username="${sf.username}" 
  password="${sf.password}" 
  sessionId="${sf.sessionId}"
  serverurl="${sf.serverurl}" 
  deployroot="projectFolder"/>
</target>

Reference For Deploy: https://developer.salesforce.com/docs/atlas.en-us.daas.meta/daas/forcemigrationtool_deploy_components.htm

Some errors that you might encounter: 1. The specified package namespace: NAMESPACE does not match the namespace for the server

Reason: This happens because the package.xml contains a tag which has a namespace value which doesn't match your org namespace.

Fix 1: Delete the tag from package.xml and then try deploy using ANT.

Fix 2: Set the namespace of your org (https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/namespaces_creating.htm) and then specify this namespace in your package.xml and try deploy using ANT.

Disclaimer: If you are trying fix 2, please do impact analysis in your org before setting namespace. I think you cannot rollback namespace after setting it. Try this in your SF developer org before attempting this in the org of your client.