Resolving Salesforce Metadata Deployment Issues

This guide is part six of ‘How to set up Continuous Integration for Salesforce.com‘, and will take you through how you can fix issues

In the previous article we set up a Bamboo job to deploy Salesforce code. By the end of this post we will have used the build.xml file to resolve common deployment issues.

Pre-requisites

This tutorial assumes that you  have the pre-requisites available from the parent article – ‘Setting up Continuous Integration for Salesforce.com‘, and have carried out the below steps of this walkthrough:

  1. Setting up Eclipse, and making your first commit to Stash;
  2. Commit your Salesforce.com codebase to Stash;
  3. Developing new features and committing them to Stash;
  4. Setting up the pre-requisites for Bamboo to execute Salesforce deployments;
  5. Set up and run your first Bamboo job.

Also, ensure that your Admin has linked your Bamboo instance to your Stash instance (and vice versa) via an ‘Application Link’. Without this the two applications will not be able to communicate with each other.

Deployment Errors related to Configuration

Some issues in deployment could be caused by a feature not being enabled in a target sandbox (for example: if you are trying to deploy LiveAgent functionality, but LiveAgent is not enabled).

These are fairly easy to catch, and should be resolved by manually checking major functionality is activated in both source and target orgs.

Deployment Errors related to Metadata files

When trying to run a Salesforce deployment using Ant – I kept hitting the following deployment errors, which caused my deployment to fail:

  1. layouts/SocialPost-Social Post Layout.layout — Error: Parent entity failed to deploy
  2. workflows/ExternalEventMapping.workflow — Error: Cannot create workflow directly; must create the CustomObject first
  3. workflows/Question.workflow — Error: Cannot create workflow directly; must create the CustomObject first
  4. workflows/Reply.workflow — Error: Cannot create workflow directly; must create the CustomObject first
  5. workflows/SocialPost.workflow — Error: Cannot create workflow directly; must create the CustomObject first

To resolve these, I modified my build.xml (see Setting up the pre-requisites for Bamboo to execute Salesforce deployments), so that it will run an Ant Task called ‘RemoveUnwantedMetadata’. This task will remove error causing files from the deployment at runtime.

You can download the two XML files here:

https://github.com/dsmorris85/salesforce-bamboo-build-xml

The ‘deploymentExceptions.xml’ file contains a task that deletes unwanted metadata files from the ‘build.zip’ file that is submitted to Salesforce.

Screen Shot 2015-05-27 at 19.57.20

This task can also be used to remove specific lines / blocks of code from individual files using the ‘replaceregexp’ Ant function:

<replaceregexp match="^ <layoutAssignments>\n <layout>SocialPersona-Social Persona Layout</layout>\n </layoutAssignments>$" replace="" flags="gm" byline="false">
<fileset dir="${src.dir}/profiles" includes="**/*.profile" />
</replaceregexp>

There are some useful tutorials:

 


<– Previous: Set up and run your first Bamboo plan

Next: Ideas / hints / tips for advanced use of Stash / Bamboo –>


 

Additional Points

  • Nothing noted yet

Leave a Reply

Your email address will not be published. Required fields are marked *


*

Seo wordpress plugin by www.seowizard.org.