Continuous Integration in Salesforce using Jenkins and Bitbucket
This blog takes you up through the advancement in continuous integration in Salesforce. I will walk through the approach of deploying only the changed element from bit bucket to destination org. The flow starts from polling the Bit bucket repository from Jenkins. If there is any change or new commit happens to the master branch of repository then Jenkins will take the changes from repository and deploy them to the org whose credentials are configured in Salesforce Migration Assistant.
Create a repository in bitbucket. Whenever there is any change in org, commit them to master branch of repository from eclipse with the help of EGit plugin.
With the help of Puttygen generate SSH key for authentication. Once the key is generated upload the public key by adding SSH key in bitbucket settings.
Installation of Jenkins:
By default there is no support for GIT in Jenkins. So go to manage plugins and install the GIT plugin from the available plugins.
Create a new project in Jenkins and provide the bitbucket repository link in the Source Code Management. Click on Add to create a credential. Use the private key of SSH key generated in puttygen which is stored with extension .ppk in local system.
Either we can run the build manually or we can poll the bitbucket from Build Triggers in Jenkins.
So, in the example I am polling my bit bucket repository for every 5 minutes using Jenkins. So, whenever any commit happens in repository the changes will be deployed to the Salesforce org. For this, install additional plugin called ‘Salesforce Migration Assistant’ in Jenkins.
Steps to install the plugin:
- Go to Manage Plugins from Manage Jenkins.
- Go to the available tab and search for Salesforce Migration Assistant.
- Install the plugin.
- Configure the project in Jenkins.(Refer the below images)
So when any new commit happens in my master branch that change will be picked up by Jenkins after the polling time and deployed to the org whose credentials are mentioned in Salesforce Migration Assistant.