BitBucket and Jenkins

BitBucket is a great place to host your open source projects; Jenkins is a great tool for keeping track of how buildable your projects are. Jenkins has become a tool used across many different languages, and it’s easy to install on any newer Ubuntu install. BitBucket hosts Mercurial project’s; Mercurial being a light weight distributed source code management tool. You probably now want to know how to build projects hosted in BitBucket via Jenkins, here it comes!

It’s really easy in fact. First off install the mercurial scm plugin for Jenkins. I’m not going to go over step by step on how you install a plugin in Jenkins. You should read up on Jenkins. Once that is done you’ll want to mosy on over to the sys config screen (manage jenkins > configure system) so you can setup a mercurial binary for Jenkins. On Ubuntu I was able to fill in the name field (I used mercurial1.4.3) and the ‘Executable’ field with ‘/usr/bin/hg’. Scroll down and save. You now should be able to setup a BB project.

Create a new job. In my case I was creating Maven 2/3 projects. Once you’ve done that you’ll configure as you like, when you get to the source code management section select Mercurial and then select the binary you created just a bit ago. In the ‘repository url’ field I put in the value you find on the overview in BB, say ‘https://bitbucket.org/joe’/someproject’. In the ‘repostiory viewer’ drop down select BitBucket, then in the ‘URL’ field that will appear put in the page in BB where the overview of the project lives. For example something like ‘https://bitbucket.org/joe/someproject/overview’.

Now you’ll probably want to poll for changes, so that not long after pushing up new code it’ll be checked out in Jenkins and run through. Easy. In the section ‘Build Triggers’ you’ll want to check the ‘Poll SCM’ box and in the ‘Schedule’ put in a logical value. These are cron expressions, for my case I used ‘*/5 * * * *’ so that Jenkins polls every five minutes looking for changes.

That’s about it. Setup the rest of the job’s settings as you wish and then save. You should be able to build the project right away to verify that it is working. Now sit back and enjoy the info Jenkins provides on builds coming into BitBucket.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>