I have a packaging org, where I am creating managed package. I would like to use an API to get the version number of the last created package.

Is there any mechanism to achieve this?


2 Answers 2


You didn't explicitly mention beta managed packages, but your question is tagged beta-managed-package so I presume that's the use case.

For the last few months, we've been automating the beta managed package upload process as part of our Jenkins builds via Selenium. Since you don't get to set the version number on beta packages, the most reliable way seems to be waiting until the beta is uploaded and then getting its version number. We do this by scraping it from the screen you get after the upload completes.

Here are the scripts we use to do the upload: https://github.com/SalesforceFoundation/CumulusCI/blob/master/scripts/package_upload.sh https://github.com/SalesforceFoundation/CumulusCI/blob/master/scripts/package_upload.py

You can see an example of the output in Jenkins here: http://ci.salesforcefoundation.org/view/uat/job/Cumulus_uat_package/lastBuild/console

The scripts use an oauth connection to the packaging org through a connected app so it takes a bit to set everything up. You also need to have xvfb and headless firefox configured (there are numerous articles on the web about setting this up).

However, once it's working, it's pretty awesome to have every commit to your master branch in git automatically deploy to the packaging org, upload a beta package, install the beta package in a test org, and run all tests. For us, that takes about 45 minutes.

I'll be documenting the setup soon.

And, yes, an API for doing the upload would be far preferable to using Selenium :)


It is similar, but a little bit different different than Dynamically get most recent version of Managed Package listed on AppExchange

The platform seems to have no API for that. But in a bit hackish way you may help yourself. In the packaging org, you find your versions at https://emea.salesforce.com/03320000000abcd?tab=PackageExports in the setup. Now we can capture the html of that particular setup page:

PageReference p = new PageReference('https://emea.salesforce.com/03320000000abcd?tab=PackageExports');
String html = p.getContent().toString();

You will have to adjust 03320000000abcd to the url where you upload your package and adjust it per org and package.

Then you parse the html code with some nice regular expressions and you'll finally get all you need. Usually you look for the topmost-non-depreciated, but you can access them all.

You can re-use this pattern to get a lot of information dynamically out of the setup, where no API is available to do the job. Sure an API would be way better. The approach is a bit risky for the future, since Salesforce may change the HTML of the setup pages. For me it worked now for years.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .