SalesforceFoundation/Cumulus — pull request #558 by jlantz (2014-03-27 16:57:19+00:00)
Title: Move destroyStaleMetadata after deploy in deployCIPackageOrg

We have hit an issue a few times where destroyStaleMetadata fails to run before the deployment to the packaging org. Most of the time, this is caused by one of two things:

1. Metadata in the package which was deleted but can't be deleted from the Metadata API such as RecordTypes. In this case, the solution is to manually delete the offending metadata from the packaging org and re-run the build.

2. A class from the previous deployment references metadata which doesn't exist in the repository of the current deployment. A good example is CustomLabels which have been removed. In this instance, the destroyStaleMetadata target tried to delete the unused CustomLabel before deploying the code but failed because the old classes which referenced the CustomLabel were still in the org. This branch aims to solve this scenario by moving the destroyStaleMetadata target to after the deployment to the packaging org. This way, the new classes without reference to the delete metadata are deployed first allowing the destroy to run since all references to the metadata to be deleted should be gone.