Adding Build Status for Bitbucket Pull Requests

Codeship News

Reading Time: 3 minutes

Ever wanted to see a pull request’s Codeship build status in Bitbucket? Our awesome user Chesley Brown has written a small NodeJS app that does just that. He was kind enough to open-source it! Here you will learn how he came up with the idea and how he built his app. Chesley takes it from here:

Github provides beautiful CI integration and after I switched my team over to Bitbucket for a better experience with the rest of our Atlassian products, it quickly became one of our most missed features. Of course, we weren’t the only ones wishing for better CI integration. There is an open issue on Bitbucket with more than 120 votes, 35 comments and currently the 15th most requested feature. This issue has been open for about a year now with no real updates from Atlasssian which told me we might have to take action ourselves if we wanted to improve our development workflow.

I have my team using Codeship for Continuous Integration and Delivery as well as using it for my own personal projects. I’ve yet to have any real complaints, the pricing is fair and their support has been very responsive for the few times I’ve needed it. We already place the Codeship Badge on all our project READMEs for a quick reference on the status of the master branch, but this didn’t provide a whole lot of value for us. We needed to know if the build was complete and successful at the point of the pull request review, just like in the Github CI integration.

I quickly realized that Codeship’s badge allowed for specifying the branch for which it showed the build status. A quick test showed I just needed someway of getting the badge into the pull request description with the right branch set to easily show the current status of the build.

All I needed was a simple app that would work with a Bitbucket Pull Request POST hook. Once a pull request is created, we just needed to automatically append the correct Codeship badge into the description. And so that’s exactly what I built with bitbucket-codeship-status.

Sign up for a free Codeship Account

As always, I’ve open sourced it so it’s available to everyone. It utilizes the Heroku Button which allows anyone to instantly have an instance of this up and running in seconds and for free. There really isn’t much to the code, just a small NodeJS app that uses the Bitbucket API to update the pull request description. But I think that’s the beauty of it. It’s a very elegant workaround for a feature that Bitbucket likely won’t introduce anytime soon.

We want to thank Chesley for providing his app to everyone and for writing his original article, which you can find here.

Subscribe via Email

Over 60,000 people from companies like Netflix, Apple, Spotify and O'Reilly are reading our articles.
Subscribe to receive a weekly newsletter with articles around Continuous Integration, Docker, and software development best practices.



We promise that we won't spam you. You can unsubscribe any time.

Join the Discussion

Leave us some comments on what you think about this topic or if you like to add something.

  • nachtgold

    it works seamlessly in my project, very impressive

    • Chesley Brown

      Glad I could help. :)

  • Since I didn’t want to go through the app creation on Heroku I write a very simple and quick javascript piece of code to inject in bitbucket: https://gist.github.com/coorasse/706d9456fcbe359744d1. This works pretty well for me :)

  • rzv

    Cool stuff. I personally use bitship on chrome.

    • Yes, Bitship got developed a bit later after this blog post. Both things are very useful :)

  • Andres Garcia

    Hey Manuel, I’ve been trying to do this but I can not make it work, I noticed a few changes when creating the webhooks, I receive the signals when creating the pull request, so codeship works perfectly but I can not see the badge inside the bitbucket pull request description.

    Do you know if this approach using the heroku app is still working?

    Thanks in advance!

  • Rafael Oliveira

    Bitbucket just launched an API for build statuses!
    http://blog.bitbucket.org/2015/11/18/introducing-the-build-status-api-for-bitbucket-cloud/

    Any plans on integration?

    • We have it on the radar, but no immediate plans to add it. We’re still a small team and resources are tight, so we want to finish / polish some other features first.

      • Rafael Oliveira

        Ok Marko. Thanks for the fast reply. Hope to see this feature soon!

        • James

          Inspired by Chesley’s great work, we’ve created a small app to listen for Codeship webhook notifications and then update the status of commits on Bitbucket using their build status API.

          Anyone able to try it out and provide some feedback/input would be helpful – https://github.com/apphaus/codeship-bitbucket-buildstatus

          • Dónal Mac An Rí

            Thanks James – works great! Provides seamless integration with Bitbucket build status API.

          • Chesley Brown

            Nice work, James! I’ll add a link to your solution on the README of my project. ?

  • John

    Bitbucket has updated there api please integrate to bitbucket the proper way :)

    • Hey John,
      as Marko wrote in the comment below: It’s on our radar but might still need some time. Thanks for getting back to our blog post so quickly after the update :)

  • David Valentiate

    These badges point to `codeship.io` which worked up until today. Now codeship.io is serving an SSL cert for for `codeship.com`. So these badges aren’t working at the moment until either codeship fixes their certs or the code for bitbucket-codeship-status is updated.

  • Michael Schramm

    added a simple call for bitbucket with php – just host it on any server: https://bitbucket.org/snippets/wodka/L84G7