Getting Started with Bitbucket Pipelines for Pull Request Automation (for CI/CD purposes)

Bitbucket Pipelines

Hi CelSius, — that’s how i call my pal 😆

Today, i’m going to make an automatic process of Pull Request.

Currently whenever we have finished a feature, we would like to create a Pull Request. And most of the time, we always passed some un-noticed bug to them.

That’s why we need to run the script in our project to run some of the checkers like :

  • Lint
    This is used for checking the source code from programmatic errors/bugs, stylistic errors, or even suspicious constructs.
  • Test
    In this case, my project are having some Unit Tests or/and End-to-End Test.
    So, if your project also having these tests, we might do the similar steps.
    But if you don’t, it’s also fine. No rush.

Those script “usually” should be run before we do the Pull Request and make sure our source code has been perfectly done.
But sadly, most of the time, we don’t. ☹

Because the checkers are really important, we need to make sure that we run all of the checker every time we do the Pull Request.

That’s why we need to automate our Pull Request action by creating an automation, so it would do the job automatically for running all the checkers whenever there’s a Pull Request.

And by doing this, we can have a breath about having our Main Branch clean from any possible errors.

Since my source code were hosted in Bitbucket when i’m writing this, so i will share about Bitbucket Pipelines.

If you have some other platform, then you also can utilize it.

Here is some of other platform :

Configuring our First Pipeline

If you have been getting used to Bitbucket Pipelines, you can jump-in directly to the Bitbucket Pipeline’s script bitbucket-pipelines.yml file.

But since it’s my first time, i would like to use the user interface feature from Bitbucket.

Bitbucket Pipeline from User Interface feature.

You need to go to your repository or your project. Then you can see the Pipeline menu.

Finishing the Two-step Verification

In this case, it’s asking me to verify the Two-step verification.
P.S : I’m not sure if this happened because of my email was linked to the Microsoft Email account. Let’s just verify it.

Two-step verification is required to enable the Bitbucket Pipeline.

Once you proceed with the verification, it will asking for the verification code.

I’m using the Microsoft Authenticator from Google Playstore.

Add new account feature from Microsoft Authenticator.

Click the Add Account feature, and choose Personal Account.

It will asking you to sign-in with Microsoft Account manually, or you can scan the QR code.

Then the code for Bitbucket will be shown-up on your list.

Take the 6-digit code to Bitbucket verification code.

Notification for Two-step verification.

After that, it will asking you to check your email and verify it by clicking Enable two-step verification button.

Two-step verification has been enabled.

Continue the First Pipeline Configuration

After the verification has been done, and we go back to our project/repository’s Pipeline again, it will showing us the Bitbucket Pipeline page.

Bitbucket Pipeline Page.

After this, we choose the Create your first pipeline link.

And then it will scroll you down to the template options.

Template options for Bitbucket Pipeline.

You need to choose one of the available template.

I’m choosing the recommended Starter pipeline because I’m creating the pipeline for a Nuxt project.

Starter Pipeline in Bitbucket Pipeline.

For now, we need to leave the content of the bitbucket-pipelines.yml file because we need to make sure it is working well.

Click on Commit file button and then it will create a new commit for the newly added bitbucket-pipelines.yml and then run it for the first time.

The first Pipeline configuration has been done.

After all the steps has been run successfully, it will show us the green status.

And it means, we are good to go!

Now, we can continue to create our own Pipeline.

Notes

For the default bitbucket-pipelines.yml file, it will always automatically run the job in Pipeline whenever someone push the code to the repository.

All pipeline’s jobs will be shown on the list.

Configure Pipeline

You can create your Pipeline based on your needs.

So for me, I’m going to configure the Bitbucket Pipeline for the Nuxt Pull Request Automation (for CI/CD purposes).

Summary

If you don’t like the long explanation, here is the checklist you have to do :

  • Simply go to the Bitbucket Pipeline feature
  • Finishing the Two-step verification (if you’re asked)
  • Start create the Bitbucket Pipeline, and choose one of the available template
  • Configure your Pipeline based on your needs

Now, you are good to go. Cheers!

--

--

--

A passionate developer who loves design

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

“Floating” in Rubies.

DevOps / SRE — Top Links Last Week

from Will Bermender on Twitter January 21, 2017 at 07:05AM

Get Silver Rates in Indian Rupee Using This API

4. Command Design Pattern

Managing JWT token expiration

A Complete Guide to DCO for Open Source Developers

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sherly Febrianti

Sherly Febrianti

A passionate developer who loves design

More from Medium

Setting up SSL for multiple GIT Accounts (Windows 10)

Debug FreeCodeCamp Challenges Faster With This Bookmarklet

Simple Script to Create Daily Backups of Your Projects

How To Connect To A Mysql Database Remotely