How to deploy to Salesforce and Heroku in tandem

We use node.js code on Heroku and Salesforce.com together for our application. Over the course of the project, we need to deploy code to both these environments in tandem. That is, if we have a new requirement and it needs changes in both Heroku and Salesforce.com, then such a change should be deployed to both of them or to none (if any of them fails). While we can have a Continuous Integration tool (like Travis CI/Jenkins) for Heroku and Ant builds and deploy to Salesforce.com (through Force.com IDE), I’d like to know if there’s a way to deploy them both together (considering both of these as an atomic process).

Salesforce.com code -> Salesforce.com instance
Node.js code -> Heroku instance

We have dev, uat and stg for both SFDC and Heroku and would like to evaluate our options.

Suggestions welcome !

Answer

Unfortunately there is no way to perform these two deployments in a truly atomic operation, since while they are from the same company Salesforce.com, the technology stacks and servers are not as yet aligned.

Single Script to Rule them All! Thus the best option in my view is to align through a single common scripting approach leveraging source control repositories (ideally different sub folders of same one, if they truly share the same release cycle) containing all the components to be deployed/pushed. Once you have your releases in repos create release tags (recommend you use the same format for clarity), invoke an Ant / Maven build script to take the tag name invoking the required Heroku ‘push’ and Salesforce ‘deploy’ operations in one operation, it can then easily be bootstrapped from your CI if needed.

Salesforce Ant Integration and who goes first? Salesforce provide the Migration Toolkit that provides an Ant task for the purpose of taking localling exported files (from source control) and pushing into a target org. Since both are atomic you don’t have to worry about them individually, but you do have to consider if the second deployment fails, i personally would do the Heroku deployment first, since its easier to rollback or version deploys (ideally). Where as once the Salesforce deployment completes you would not easily be able to roll it back.

Which build script technology to use? Looking at the two, Ant is favoured for Salesforce, Maven is favoured for Heroku. If you go with the view that the Heroku build is driving the process, you can actually by the looks of it, call Ant tasks from a Maven script, see here for more information on this. Otherwise you can of course use Ant and its ‘exec’ task to call Maven.

Hope this helps give you some initial steer, of course the devil is in the detail with these things!

Attribution
Source : Link , Question Author : markgarg , Answer Author : Andrew Fawcett

Leave a Comment