Friday, November 16, 2007

Get your build fixed faster... broadcast your failures!

We've been talking about setting up a build box light for ages.

The other day my project manager bought a USB Visual Signal Indicator. An hour of hacking .. and we now have a light that's green on a passing build and flashes red on a breaking build.

We are using CruiseControl.Net as our build machine, so I controled the light using a custom build publisher.

The result we are experiencing is the build is gets fixed faster. I have a few theories as to why.

Here is the code...

using System;
using System.Text;
using Exortech.NetReflector;
using ThoughtWorks.CruiseControl.Core;
using ThoughtWorks.CruiseControl.Remote;


namespace FlashLightPublisher
{
[ReflectorType("flashlight")]
public class FlashLightPublisher : ITask
{
[ReflectorProperty("goGreenOnPass", Required = false)] public bool GoGreenOnPass = true;

public void Run(IIntegrationResult result)
{
StringBuilder DeviceName = new StringBuilder(Delcom.MAXDEVICENAMELEN);

int Result = Delcom.DelcomGetNthDevice(Delcom.USBDELVI, 0, DeviceName);

if (Result == 0)
{
throw new Exception("no usb device");
}

uint hUSB = Delcom.DelcomOpenDevice(DeviceName, 0);
switch (result.Status)
{
case IntegrationStatus.Success:
if (GoGreenOnPass)
{
Delcom.DelcomLEDControl(hUSB, Delcom.REDLED, Delcom.LEDOFF);
Delcom.DelcomLEDControl(hUSB, Delcom.GREENLED, Delcom.LEDON);
Delcom.DelcomLEDControl(hUSB, Delcom.BLUELED, Delcom.LEDOFF);
}
break;
case IntegrationStatus.Exception:
case IntegrationStatus.Failure:
Delcom.DelcomLEDControl(hUSB, Delcom.GREENLED, Delcom.LEDOFF);
Delcom.DelcomLEDControl(hUSB, Delcom.REDLED, Delcom.LEDFLASH);
Delcom.DelcomLEDControl(hUSB, Delcom.BLUELED, Delcom.LEDOFF);
break;
case IntegrationStatus.Unknown:
Delcom.DelcomLEDControl(hUSB, Delcom.BLUELED, Delcom.LEDON);
break;
}

Delcom.DelcomCloseDevice(hUSB);
}
}
}


Our ccnet.config file contains the following snippet...


...
<publishers>
<flashlight/>
...
</publishers>


Note: We have few sequencial builds set up so we don't class the build as green until all the builds have passed. I therefore have all the builds able to make the light go red, but only the last build make it go green.
Post a Comment

GitHub Projects