Is it possible to retrieve packages from Setup>Create>Packages(not from Setup>Installed Packages) in the way like we can retrieve installed package and deploy it to destination environment. I am thinking a way to automate this process with CI. Thanks

  • Are you asking for automation to A) extract the source code from your packaging org and deploy it in source code form to another org or B) deploy (install) the managed package (in non-source code form) in another org? – Keith C Mar 19 '14 at 15:52
  • I mean B) to deploy unmanaged package/some verion of the release of manage package(which is released in Setup>Create>Packages with some install link ) and install this package on target environments. – Natallia Mar 19 '14 at 18:35
  • There is an idea to leverage the test automation tool to perform this routine. – Natallia Mar 19 '14 at 18:36

Since Summer '13, the Metedata API has included an "InstalledPackage" type. The package is identified by its namespace and its version rather than the URL that you use to install manually. (If the managed package has a password you also have to supply that.) The target org is identified by a username and password (including the security token).

So you can use something like Ant to deploy a package to various destination orgs as part of your Continuous Integration. See Andrew Fawcett's “Look ma, no hands!” : Automating Install and Uninstall of Packages! for how to do this.

(As we do a lot of this sort of work in house we have wrapped all this in an Ant task - not published I'm afraid - that also first checks the currently deployed version and only installs if necessary. This saves time because by default the managed package installation process that can take many minutes runs even if the same version is already present.)

PS The above only relates to the "manage package" part of Natalia's comment on the question. A separate answer may be needed to cover the "unmanaged package" content - see comments below.

| improve this answer | |
  • 1
    Thanks for the reference Keith, though sadly Package definitions as defined under Setup > Create > Pages are not available via the InstalledPackage component, this relates only installed packages not those defined in the development org. This question is similar to this one salesforce.stackexchange.com/questions/24569/… – Andrew Fawcett Mar 19 '14 at 19:21
  • @AndrewFawcett The second comment on the question mentions deploying "some verion of the release of manage package" which fits with IntalledPackage. But yes maybe there is something more being asked. I'll qualify the answer. – Keith C Mar 19 '14 at 19:37
  • Thanks Keith and Andrew. Andrew, you got my idea exactly. Thanks. I've tried InstalledPackage feature and it can perfectly used to automate deployment of already installed packages. But I'd like to automate the installation of released package, not installed. – Natallia Mar 19 '14 at 19:43
  • @Natallia Ok well I'm still lost but that's fine as long as its clear to others. – Keith C Mar 19 '14 at 20:13
  • Yeah I have to say after that last comment i am as well... :-) @Natallia if you want to 'automate the installation of released packages' then Keith's answer is spot on! Whats confusing is your talking about the packages shown under Setup > Create > Packages, maybe thats because your saying i want to install the packages resulting from these. Anyway I actually think you should consider Keith's answer as the correct one now. – Andrew Fawcett Mar 19 '14 at 22:27

You are able to move a Package (in the Setup->Create->Packages sense) from one DE org with a little bit of ant work and one step in the Web UI.

The two key things about deploying to an unamanaged Package in a DE org is to specify a element in your package.xml with the Package name and to explicitly list all metadata including subtypes like CustomField and WebLink. Fortunately, when you retrieve all metadata from a package in the source org, the Metadata API builds the package.xml in the right format for you.

The steps below assume you already have the Force.com Ant Migration Tool setup with a basic build.xml file with credentials to your org per the documentation.

Step 1: Retrieve the Package's Metadata from source org

In your build.xml, add a target:

<target name="retrievePackaged">
  <delete dir="packaged" />
  <mkdir dir="packaged"/>

Step 2: Create the Package in target org

Since the Metadata API won't let you create a Package, you have to do this step manually. In the target org, go to Setup->Create->Packages and create an unmanaged package with the same name as in the source org. Once the package exists, you can redeploy metadata into it so this is just for the first time you deploy the package to the target org.

Step 3: Deploy the Metadata to target org

Add a target to build.xml:

<target name="deploy">
  <sf:deploy username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" deployRoot="src" runAllTests="true" maxPoll="200" />

** Bonus Points

We use this to automate the process of sending our code to our packaging org for bundling into a managed package. By providing a fullName in package.xml and an explicit manifest in package.xml, we no longer have to go to Add Components in our packaging org as the package.xml does the job for us. If you want to generate the package.xml from metadata files on the filesystem or automate the uninstall of all metadata in the package for clean CI builds, all the build scripts we use are available in the project https://github.com/SalesforceFoundation/Cumulus

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.