Build Status and Deploy Button with a Raspberry Pi, Octopus and

Apr 23, 2013

I made a build status and deploy button using a Raspberry Pi that connects to our Octopus deploy server and our build server.

Why? Well it all started a while ago I got a Raspberry Pi mini computer to muck around with at home. I was pretty blown away with it for a number of reasons

  1. Cheap – enough said.
  2. Power consumption – they don’t use much, you can even run one on a backup phone battery.
  3. You can swap SD cards to swap the OS – It’s like the olden days when your machine used to boot from floppy (but you only need one thank goodness).
  4. They are small – well smallish.
  5. They have GPIO pins (General Purpose Input Output pins).

They had me at cheap! It wasn’t until it arrived that I realised how cool being able to mess with programmable pins was. This started my journey, at first I was reading articles on the web and eventually I bought this book Teach Yourself Electricity and Electronics, 5th Edition to get a more comprehensive understanding about electronics.

A few months later and we are using Raspberry Pi’s at work for fun and profit. Having a device on my desk at work for testing gave me the idea for a project that was suitably simple. I wanted to make something to learn about electronics and practise some soldering. The idea was to make some status LEDs indicate the health of the build at work and have a button for deploying our software. I managed to get it working, this is what it looks like, some people have said that it bears some resemblance to a Nyan Cat.

Raspberry Pi Deploy Button

Raspberry Pi Deploy Button

A few people have been asking about how it went. I made a video so you can see for your self.


I wrote the software that runs the button and the LEDs in Javascript using node.js. I used node because it has heaps of packages that communicate via http and with the GPIO pins. Getting the software up and running was rather quick.

I found it amusing to operate electronics using a high level language. To read and write from the GPIO pins I tried a number of packages and ended up using onoff  because it supports reading via an interrupt rather than polling, which thrashes the CPU.

We are using for our build server and Octopus Deploy for our deploy server. I used request.js for getting the build and deploy status via http.

To start a deploy, Octopus has a command line tool written in .net that lets you remote control the server. I thought this would be the most stable interface to code against, so I tweaked the code to get it to run in mono, but I discovered there is an issue in mono that I am still waiting on a fix for. It should be possible to use request.js for creating and deploying a release, but I can wait a little longer.


I thought software was hard, then I started learning about electronics. It’s amazing computers work at all.

For the LEDs, I am using an Integrated Circuit with a Darlington Array of transistors on it, this allows a higher voltage to power the LEDs and protects the CPU which is connected to the pins. Each LED requires a different resistor according to its specifications. I found this handy site that talks about GPIO pin interfacing.

You would think the button would be pretty easy, it is either on or off right? it’s a bool! Well not quite, the button needs to be grounded so that it can be read correctly. Also you want to know what the value is when it changes without using your CPU to poll all the time. So you need an interrupt which signals your program when the pin changes state. To top it all off, when you go to read the value, it might not be correct as electricity bounces. To counter bounce you can write some code to trade off responsiveness with accuracy or use a low pass filter (a circuit).


I really enjoyed making this, it started off as a simple idea to practice soldering, but turned into something that is rather useful. I think for our team, it sets the bar for how easy the deployment of our software should be. It is a physical symbol that the deploy is one step, and any features that get deployed, need to a part of that step. If anyone makes it more complicated than that, then they are going to have to get the soldering iron out.

Create a Chrome Extension in 5 Steps

Sep 25, 2012

If you follow along, by the end of this post you’ll have a working Chrome extension.

One of the great things about web programming is that the parts are in a standard structure. Because of this standard structure, it’s possible to modify other people’s programs. This client side modification is usually done with user scripts.


There are various reasons why you might want to create an extension. For example, you could make an extension to:

  1. Improve your browsers general functionality to be more powerful and useful
  2. Make a specific site more useful
  3. Circumvent poor security
  4. Automate something

Other browsers

This post will show you how to get started with Chrome extensions, however you can do similar things in other browsers, for example in Firefox has grease monkey plugins.

Creating your first Chrome extension

Step 1
Create a directory. Everything your extension needs will go into this directory.

Step 2
Create a file in the directory called manifest.json with these contents:

 "name": "Hello World",
 "version": "1.0",
 "manifest_version": 2,
 "description": "Say hello.",
 "background": { "scripts": ["background.js"] },
 "browser_action": {
 "default_icon": "icon.png"
 "permissions": ["tabs"]

Step 3
Create and copy in an icon named icon.png

Step 4
Create a file called background.js with these contents:

chrome.browserAction.onClicked.addListener(function(tab) {
 alert("hello world");

Step 5
Open Chrome, click the spanner, extensions, click developer mode.
Click ‘load unpacked extension’, find your folder and click ok.

That’s it, your extension is done. Your code will load when Chrome starts, a button will show up next to the navigation bar, and the onClicked event will fire when your button is clicked.

Three weeks of Python programming

Feb 14, 2012

I recently discovered the 50apps challenge, a year long challenge that publishes weekly programming exercises.  I hope to be able to participate in as many of the exercises as my schedule permits. The first three weeks of the challenge were focused on exploring the Python programming language. These are my notes.

Week 1

I wrote a web crawler in Python. It works by getting the contents of a web page, finding all the links and following them to a specified depth, while scanning for some search text.

I found Python pretty straightforward to work with despite not having used or even read it before. I was surprised that I managed to complete the exercise in two hours. The documentation was good. Finding the regex method to use took the most time, and having to explicitly cast was annoying.

Week 2

I created a Django website for the web crawler created the week before.

I used Django, which is a Python web framework. It was a larger framework than I was expecting, coming in over four megabytes, but it did seem to have a lot of features. It took a little longer than I wanted to get something going: I spent two hours getting a basic form and another two hours adding some more advanced features. I personally prefer Sinatra-style frameworks like Express as they seem to make more sense to me.

I made my application reuse the code I wrote the week before. I am wary that it could create a security hole, depending on how Django cleans form input data. The code to reuse the previous functionality was a little more complicated than it should have been because of the way I wrote the code from the week before, but I wanted to see if I could reuse it without changing it.

I spent over an hour trying to get Django working with Google app engine. I quit while I was ahead because the proposed solutions I found looked hacky or required another package to install. It seemed pretty painful compared to other hosting sites like or heroku. To Google app engine’s credit, the logging was good.

Week 3

This week we explored Python’s functional programming side. I wrote a website that graphs word statistics for a given page. The logic for gathering the statistics was to be written without using looping constructs. I used a primitive form of TDD just by using the command line and the assert function in Python. Later I integrated the statistic logic into the web interface, this time I avoided trying to reuse previous code as it was rather different and I was running out of time.

It took about an hour to get a filtered list of words with a count and an hour to get rid of duplicates, limit the results to only ten words and find shortest and longest words. To hook it all up to the web interface was another hour. A lot of the time was spent re-reading the documentation and head scratching.

By the way I ran the tool over my blog and I use the word ‘I’ a lot. :)