3

I'm using CircleCI to run tests. I have a Git branch. After a feature is done, the work is committed and pushed to the branch. CicrleCI build and run tests.
What would be great is to update Managed Package, which is developed in a Developer Edition org, with new items or remove items from it. In case of successful tests it would be nice also to upload the package to get new installation URL.

Is it possible to update and upload package upon code commit to Git?

EDIT 1.

I figured out that I can put specific target in build.xml, which will use specific package.xml with description of a Managed Package. Executing deploy method components specified in package.xml will be updated in specified Managed Package.

package.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>DevMuza</fullName>
    <apiAccessLevel>Unrestricted</apiAccessLevel>
    <description>DevMuza Package to test CircleCI.</description>
    <namespacePrefix>dev_muza</namespacePrefix>
    <types>
        <members>ContactCounter_Ext</members>
        <members>ContactCounter_Ext_UT</members>
        <name>ApexClass</name>
    </types>
    <types>
        <members>CountContacts</members>
        <name>ApexPage</name>
    </types>
    <types>
        <members>Account.Number_of_Contacts__c</members>
        <name>CustomField</name>
    </types>
    <version>40.0</version>
</Package>

build.xml:

...
  <target name="updatePackage">
    <sf:deploy username="${sf.username}" password="${sf.password}" sessionId="${sf.sessionId}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" deployRoot="." singlePackage="true" />
  </target>
...
2

From the ISVforce Guide - Create and Upload a Managed Package

You can also upload a package using the Tooling API. For sample code and more details, see the PackageUploadRequest object in the Tooling API Developer Guide

Which takes us to PackageUploadRequest. It shows how to use the Tooling API to automate the creation of a new managed package.

The Managed Package itself is represented by MetadataPackage.


Updating the package components

At this stage I suspect you would need to use the Metadata API to update the package definition to add or remove components. There is an example of this in Salesforce Metadata Api/ Tooling Api to build changesets.

Also, keep an eye on Salesforce DX and Packaging 2.0. There are likely to be changes in this area in the coming future.

2
  • And how to update it with new components (like fields, custom settings, classes, pages, etc.)? Jun 30 '17 at 12:41
  • @Chiz Using the Metadata API to update the package would be one option. There may be further options with the Salesforce DX CLI. Jul 1 '17 at 4:21
1

I just read the title - After reading the question I see this answer is not what you were asking. Leaving it here though in case it helps someone looking at this question thinking it is asking what I thought it did. My Bad

You can update and or install a package using the metadata API. I use this in postman as an example

<?xml version="1.0" encoding="UTF-8"?>
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <env:Header>
            <urn:SessionHeader xmlns:urn="http://soap.sforce.com/2006/04/metadata">
                <urn:sessionId>[SESSION ID HERE]</urn:sessionId>
            </urn:SessionHeader>
        </env:Header>
        <env:Body>
            <createMetadata xmlns="http://soap.sforce.com/2006/04/metadata">
                <metadata xsi:type="InstalledPackage">
                    <versionNumber>[PACKAGE VERSION NUMBER HERE]</versionNumber>
                    <fullName>[PACKAGE NAME HERE]</fullName>
                </metadata>
            </createMetadata>
        </env:Body>
    </env:Envelope>

Make sure you have a SoapAction header with a value of "" and a Content-Type of text/xml

URL: https://[pod].salesforce.com/services/Soap/m/40.0/[orgId]

0

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.