CI/CD built into Bitbucket

Continuous integration (CI) and continuous delivery (CD) is set of operating principles and practices that enable development teams to deliver code changes more frequently and reliably.

In case of Salesforce development it is really make a lot of sense when you have at least 2 developers, but can be helpful even for single dev!

Just imagine: you as developer(or customer) wants to deploy some recent changes to multiple orgs at same time. How you can do this?

There is a few options:

  • Manual deployment – when you open your IDE(or using ant command) and configure connections to different orgs
  • Change sets – using Salesforce built in feature.
  • Using Bitbucket Pipelines – the most beautiful an easy to use tool and we want to let you to know how to configure it.

This article is based on How to configure Apache Ant Migration Tool.

Bitbucket Pipelines & Deployments

What is it?
Bitbucket Pipelines is an integrated CI/CD service, built into Bitbucket. It allows you to automatically build, test and deploy your code, based on a configuration file in your repository. 

How to set it up?
To set up Pipelines you need to create and configure the bitbucket-pipelines.yml file in the root directory of your repository.

So for example this is how defailt SFDX project root folder looks like.

Default SFDX project folder structure.

The only thing left is our new yml file – bitbucket-pipelines.yml
You can create it manually or using bitbucket web interface.

To create this file using web interface you have to login to your bitbucket account, then go to your repository and click on Pipelines and when page is reloaded scroll to the bottom and select Other options.

Default configuration file.
# This is a sample build configuration for other languages.
# Check our guides at for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: amkor/docker-salesforce

      - step:
            - ant -buildfile build.xml deploy_fast -Dsf.username=$ORG1_SFDC_USERNAME -Dsf.password=$ORG1_SFDC_PASS$ORG1_SFDC_TOKEN  -Dsf.namespace=$ORG1_SFDC_NAMESPACE -Dsf.serverurl=$SFDC_SERVERURL_LOGIN -Dsf.dir=src
      - step:
            - ant -buildfile build.xml deploy_fast -Dsf.username=$ORG2_SFDC_USERNAME -Dsf.password=$ORG2_SFDC_PASS$ORG2_SFDC_TOKEN  -Dsf.namespace=$ORG2_SFDC_NAMESPACE -Dsf.serverurl=$SFDC_SERVERURL_LOGIN -Dsf.dir=src

The code below contains example pipeline configuration. Once you push this file to you repo and go to Pipelines page you will be able to run pipelines manually.
There is two configuration that use different environments: ORG1 and ORG2.(To configure that variables you have to follow to the Repository variables setting under you repository settings page).

Run pipeline modal.

Now you have to select branch you want to deploy and then select Pipeline(configuration). Thats it 🙂 Once deployment finished you can see the status. And in case of any issues you will be able to check full deployment log.

If you need help with this article(or any others) you can contact us using contact form or our email: [email protected]

Comments are closed.

Works with AZEXO page builder
© All rights reserved. Theme by AZEXO