Hello again! In Part II of this series, we talked about linking Jira and Bitbucket together to allow teams to move at a quicker pace. Now let’s dive into Continuous Deployment (CD) and how Bitbucket Cloud can be used in the CD section of our workflow. We will be using the pipeline and deployment features in Bitbucket Cloud to automatically build and deploy our code when a commit takes place. For the example in this article, I will create a very simple docker file to use for our build, and we will discuss the use of a bitbucket-pipelines.yml file in order to take advantage of automatic deployments.

Setting Up and Editing Pipelines

The pipeline can be set up in a number of different scenarios, but for the purposes of what we are exploring today, we will set up a test environment, a stage environment, and our production environment. We will build our docker image and deploy that image to docker hub where we can use it to deploy to test, stage, and production. These environments are set up in the “Repository Settings” section of Bitbucket Cloud and can be customized (see example image on the right). There are several settings in this section to include variables and keys that may be used for your build, and many integrations that can be installed.  

Once everything has been set up, you can start to edit the bitbucket-pipelines.yml file for your pipeline. This file is made up of different sections for each step in your pipeline, and I have created a very simple file for our example. This file can call any scripts that you create from your repository to build and deploy your application. Now that we have some insight into what is being used, we can take a look at how it works.

The Deployment Process

When I commit a code change, I will have my pipeline build and deploy my code automatically to my test environment. When everything has been validated, the application will be deployed to my staging environment. When I am ready, I can click a button to deploy my code to production. All of these steps can be automated or set to be manually triggered as needed.

The “Deployment Dashboard” in Bitbucket Cloud allows you to see all of your deployments, each commit and where it is deployed, and a history for each of your environments. You may have a different commit running in each of the three environments. This feature is extremely helpful to get an overall look at what is going on with your application and see what your environment looks like in real-time.  In the example on the left, you can see that my latest commit, #48, is in Test, and commit #47 is in stage and production.

When I click on the “Test” box, I can take a deeper dive into what is deployed into that specific environment. A list of commits, the code diff, and all Jira tasks that were linked during the check in process are available. And by clicking any of those commits, I am taken to the code change and can see inline comment and changes to the source code.

Our next step will be to deploy our code to our stage environment, which can be done automatically or manually. I chose to trigger this manually by clicking the “Promote” button in the box. When I click the “Promote” button, I am presented with a screen that allows me to see the commits, the code diff, and any Jira issues that are tied to this commit. Now that we have our code change in our stage environment, we can validate our changes, and then simply click “Deploy” and our code is deployed to production.

In this article, I have used an extremely simple deployment process to demonstrate some of the features of Bitbucket Cloud as it relates to CD. In reality, the bitbucket-pipelines.yml file would probably be augmented with scripts to deploy to many different environments. Those could be cloud environments, private data centers, or basically any place that you wanted to deploy to.

I hope that this article gave you some insight as to what is possible using Jira Cloud and Bitbucket Cloud together to streamline your deployment process and empower your teams to move quickly and efficiently.

 Do you want to learn how to streamline your deployment process? Contact Us to find out how.