Bitbucket Pipelines is an integrated CI/CD service built into Bitbucket Cloud that’s integrated into the UI and sits alongside your repositories. It allows you to automatically build, test, and even deploy your code based on a configuration file in your repository.
CI/CD tools are an integral part of a software team’s development cycle. Whether you’re using it to automate tests, a release process, or deployments to customers, all teams can benefit by incorporating CI/CD into their workflow.
Some of the features of pipelines are:
It is very easy to get started with the Bitbucket pipelines. It’s a 2-step process to configure a pipeline and there is a number of templates of language is available to get started.
Bitbucket Pipelines is a cloud-native CI/CD tool so you never have to worry about provisioning or managing physical infrastructure, meaning more time focusing on other priorities.
Bitbucket pipeline provide integration to various tools used to test, scan and deploy different sort of applications in a plug and play fashion.
So for this integration, they provide pipes (A pipe is a custom Docker image for a container, which contains a script to perform a task. There are a bunch of available Pipes, but you can write your own too.) It is similar to the plugins in other CI/CD tools.
Pipelines offers a robust set of deployment functionality that provides teams the confidence and flexibility to track your code from development through code review, build, test, and deployment all the way to production.
For more sophisticated workflows you can create up to 10 environments to deploy to, and see what code is being deployed where via the deployment dashboard.
Increased visibility and collaboration
As we know, Atlassian provides various tools like Jira, confluence, etc which can be easily integrated with the pipeline which leads to an increase in visibility and collaboration.
For example, we can simply link Jira with the bitbucket pipeline. Along with that deployment details like which version or which build number is currently deployed on the server and other information regarding tasks, issues, etc can be easily visible from the Jira board.
Pipelines pricing is based on a simple, consumption-based model of build minutes used, and every Bitbucket plan includes build minutes.
|Plan type||Build minutes per month|
Create your first pipeline
I have a simple python flask application available here. I used this python application to test and deploy code to a server.
Firstly, we need to create a pipeline and push it to the repository. Or we can directly create a pipeline from the bitbucket interface in the pipeline section.
Also we need to enable the pipeline in the repository in the pipeline configuration.
This is simple bitbucket pipeline which run on each commit.
image: python:3.8 pipelines: default: - step: name: Test caches: - pip script: - python test.py - step: name: deploy to the server deployment: Production script: - pipe: atlassian/scp-deploy:0.3.3 variables: USER: 'ubuntu' SERVER: '<server-ip>' REMOTE_PATH: '/home/ubuntu/app' LOCAL_PATH: 'main.py'
Bitbucket pipeline uses YAML to config the pipeline. It uses an image to run each step inside the docker container. Each step runs in a separate docker container to run the script. We also can use separate images for each step.
Here, in this pipeline, we use a docker image of
python:3.8 to test and deploy a python application.
The above bitbucket pipeline will show following interface in bitbucket UI.
Some basic Configuration keywords
With a basic configuration, you can do things like write scripts to build and deploy your projects and configure caches to speed up builds. You can also specify different images for each step to manage different dependencies across actions you are performing in your pipeline.
A pipeline is made up of a list of steps, and you can define multiple pipelines in the configuration file.
In the following diagram provided below, you can see a pipeline configured under the default section. The pipeline configuration file can have multiple sections identified by particular keywords.
default – Contains the pipeline definition for all branches that don’t match a pipeline definition in other sections. The default pipeline runs on every push to the repository unless a branch-specific pipeline is defined.
branches – You can define branch-specific pipeline under branches section.
tags – Defines all tag-specific build pipelines.
pull requests – A special pipeline that only runs on pull requests initiated from within your repository. It merges the destination branch into your working branch before it runs.
custom – If we want to trigger a pipeline manually or from the bitbucket UI then we can use custom keywords in the steps.
Also there is much more things you can use in bitbucket pipeline, so you can use the reference below for that.
In this blog we learn what is bitbucket pipeline and hoe can we configure pipeline.
Bitbucket pipelines are very simple to create and configure. It’s just a two-way step to configure and enable pipelines, we can even use different templates based on our application and programming language.