Make BitBucket work harder for you in 2018: five productivity boosters
Okay.. BitBucket isn’t a cure for cancer. But it does offer a few nice hidden perks that are easy to set up and increase your productivity. Here they are.
NOTE: if you’re a swashbuckling BitBucketer that has done everything already, you probably know most, if not all, of this stuff. So, TL;DR: I’m touching on Pipelines, HipChat / SourceTree integrations, branch permissions and account-wide code search.
What frickin’ BitBucket?
An intro of BB for newcomers. Hint: nothing to do with Dwight and his beets as stated above. You might have heard of Git, GitHub, Subversion or code versioning before? This is up that same alley.
BitBucket helps you to store your code, and any version of your code that you’ve deemed worthy of saving. It also lets you share your code with others, and lets you control how others can contribute to your code, with any amount of approval bureaucracy that you may deem necessary.
It’s all about “your code” becoming shared code, but just how that happens is controlled by you. There are various workflows that have become a way of working amongst the community, although today, modern DevOps practices have begun to re-encourage an alternative, simplified approach that has been around for years. These workflows, their pros and cons and alternatives are subject to a fair bit of debate, which I won’t go into right now. If you’re up for it, grab some popcorn and read the comments thread at the bottom of this article or this Stack post, for example.
BitBucket supports both Git and Mercurial source control systems, and packs a ton of features, a few of which I’m about to reveal to you, free of charge :) Speaking of free, BitBucket is free (for smaller teams).
Looking at the fancy bagel below, BitBucket fits into a whole family of product development, task management, wiki, Continuous Integration and similar tools from the company Atlassian, hailing from Sydney. Go Aussies!
Feature 1: Pipelines
If you know GitHub’s Travis, then I can tell you that Pipelines are BitBucket’s answer to Travis. If you don’t know Travis, then just ask yourself this:
As a developer, if I had BitBucket grant one wish for me, what would it be?
At the top of my list is definitely “help to roll my code straight onto a staging and production server, just by me pushing it to a certain branch”. Right? Well, BitBucket Pipelines supports exactly that. The cool thing about it is that it’s integrated straight into your repository. All you need to do to activate this feature is to set up a bitbucket-pipelines.yml file in the root of your repository. Here’s a simple starter.
You can use BitBucket’s config validator to make sure it’s alright (YML files are crazy about whitespace). Here’s a simple example of a config file:
So, in the above file, “dep deploy” would point to a PHP Deployer script which has further instructions on what to do within the Docker container.
NOTE: To complete the release process and get Continuous Delivery going, you will also need to set up a deployment server, choose or create a Docker container for your server environment and set a deployment script using a framework such as PHP Deployer, topics which are beyond the scope of this post. Maybe I’ll post an article dedicated to that later in the year.
Anyway, sailing on to the next productivity tips: HipChat and SourceTree integration.
Feature 2: get BitBucket notifications into your HipChat rooms
If you’re a true Atlassianite and therefore are pro- stuff like this, you’ll probably already be hip to HipChat. Or Slack for that matter, this works for both. It’s just a tad easier for HipChat since BitBucket has native support, so you can just tick a few boxes and you’re done.
Go to your BitBucket repo Settings, choose HipChat Integration. If you’re logged into your HipChat account, you’ll get a list of rooms to pick from. Choose your room and tick some boxes on what’s notification worthy as shown in the choices below. No more flooding your emails, having to go peek in your repo or do git fetches to check whether that commit you’re waiting for your colleague in another country to finish has been pushed or not.. you’ll get pinged the second the code arrives in the repo.
Feature 3: see your pipeline progress in SourceTree
Again, if you’re an Atlassianite, you’re already using SourceTree. It’s hard to live without it once you, er.. git going :) It’s 100% free and works on both OS X and Windows, so download that thing and try it for yourself already!
The intricacies of using SourceTree warrant a separate post, so I won’t go into that much detail. What I want to point out is a really nice feature in SourceTree: you can see the progress of your currently running pipeline (Feature #1 in this article) right in your SourceTree branch view. How neat is that?
Feature 4: branch permissions
Have you ever had a team that’s dispersed over a large geographic area, and has had different levels of authority over code? I have.
Like, some devs shouldn’t be allowed to push stuff in the master branch, which would initiate a deployment into the production server, and some devs should. Some devs should have the authority to delete branches, some not. Enter branch permissions: it allows you to define each and every user’s access per branch, just how you want it. Read more about BitBucket’s branch permissions here.
Feature 5: account-wide code search
This thing is a beauty, especially if you’ve already been on BitBucket for a long time and have like 300 repos on your account.. You can search for a snippet of code within all those repos from one location! It’s hard to explain how awesome this is, you just need to try it for yourself. Just type in a search string on the Code Search page and BitBucket (after it has indexed all code in every repo on your account) will go scouring your repos for occurrences of that string. I know, sounds trivial, but it’s pretty sweet to find that snippet of code you needed, in some project you didn’t even remember existed.
From the search documentation page, it’s clear that you can choose an account as the search scope, which is what I’ve done in the below screenshot. I looked for a string and it went off on a quest to find it within all the repositories it had previously indexed and peppered up for an account-wide search.
Well, have fun and may you be more productive with these little tips.
Share with your fellow BitBucketeers!