(234) 463-4655 contact@focalcxm.com
Code migration in Salesforce development is not a straightforward process because of the multitude of artifacts that need to gracefully move from one environment to another. Salesforce and several partners in the ecosystem offer several ways for a successful migration.

In this blog, we intend to talk about migrating the code using ANT. Here we talk about setting up the CICD process for a Salesforce project using the following:

  • ANT migration tool,
  • Bitbucket pipelines and
  • Docker.

To keep it simple, we have created a folder “FocalPackage” that contains the “package.xml” which defines the metadata that we need to work on during the deployment.

The package.xml contains all the basic metadata such as Classes, aura components, triggers, etc. Here, we do not want to customize the folder structure so the retrieved code will adhere to the standard structure.

Next, we need to set up the ant migration tool; the folder structure looks like this

Here are the details of each of the files

  • ant-salesforce.jar – This is the Force migration tool, it can be downloaded from the URL.
  • build.properties – It contains static property details like salesforce instance, user account details etc. Here I have created Source system details using prefix sf and the target system details using the prefix ‘sft’.
  • build.xml – Contains ant commands and logic that are used to execute to retrieve and push code.
    • retrieveFocalCode

    • deployFocalCode

    • postToChat

The above commands “retrieveFocalCode” and “deployFocalCode” retrieve metadata from the source org and save them in a local folder ‘FocalCode’ and deploy it to the destination org. Here is the basic structure of the FocalCode. The postToChat command posts a build update to a Google Chat room via webhooks.

Now let us setup the pipeline in the bitbucket environments.

  • Enable pipelines – From your project in the Bitbucket, choose settings > Pipeline Settings then enable pipelines.
  • Create bitbucket-pipelines.yml – This file leverages johnjvester/docker-salesforce docker image. This file contains a simple pipeline that deploys the code to the target org which is mentioned in the build.properites.

The pipeline will be triggered right a commit on the branch and will push the changes on to the target org. The deployment status will be posted on to a Google chat room.

This is a simple CICD pipeline setup for a salesforce project on bitbucket that we started integrated into our Salesforce development. In future posts, we will be writing about integrating code scanning tools in the CICD process, spinning new scratch org and run all test cases, etc. so, stay tuned for the updates. We will also be introducing AutoRabit, our partner that specializes in enabling CICD for Salesforce platform.

The basic structure of the project can be downloaded from this link Basic Code