Salesforce Metadata Api/ Tooling Api to build changesets

It turns out you can directly retrieve and update changesets directly with the Metadata API.

Via Sean Harrison‏:

Pro tip: U can retrieve the contents of a change set incl. manifest with the packageNames parameter on

And it really is that simple.


I made a test changeset in a sandbox with a single component:

enter image description here

Note the "Change Set Name" of TestCS.

Then over to Workbench for a migration retrieve:

enter image description here enter image description here

Complete the Retrieve and download the resulting package zip file: enter image description here

As part of the round trip exercise, extract the zip. Note the presence of the OpportunityBatchable.cls in the classes folder. Modify the package.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>TestCS</fullName>
    <description>Test Change Set. Updated locally!</description>
    <types>
        <members>OpportunityBatchable</members>
        <name>ApexClass</name>
    </types>
    <version>39.0</version>
</Package>

Zip the package back up. In this case it will have the TestCS folder at the root of the zip.

Back in workbench, use migration > Deploy. Select the modified zip file. Check "Auto Update Package". Press Deploy.

enter image description here enter image description here

Wait for the deployment to complete. Then reload the change set in Salesforce. Observe the updated Description!

enter image description here


So yes, you could build the changeset using Metadata API calls to update the package definition.


Updates via Chuck Liddell:

  1. Changeset names aren't unique. If there is a duplicate you will be an error:

    More that 1 developer package named "X" exists in this organization. Please rename one of packages so that is has a unique name. enter image description here

  2. On update, you can't have an empty package and rely on autoUpdatePackage. You need to include all the files that form the changeset.

Yes its possible. But rather than writing the application drom scratch in another language, consider keeping it on platform!

You can use the open source Apex Metadata API and custom metadata to define and push change sets. Here is a blog post by Andy Fawcett detailing the process: http://andyinthecloud.com/2015/06/28/custom-metadata-custom-uis-packaging-and-change-sets/

Metadata API source is here: https://github.com/financialforcedev/apex-mdapi


You can use salesforce Metadata API for this purpose . If you are familiar with ANT tool ,you will find that there is force.com migration tool in SFDC which uses ANT commands to help extract metadata and deploy to other orgs .

Package.xml is all needed by the migration tool to fetch necessary components from one org .

There are already many different tools build to automate the process of deployment .