I added twitter posts to the FIRST FRC Field Management System, so that interested parties could get the results of a match in near real time.  Since twitter is focused around sending small messages I thought it would be a great mechanism to notify team members when the status of the build changes.  Most build solutions have a way already to do this, but they come in the form of an email or a custom program that sits in your tray waiting to notify you.  Twitter messages on the other hand can be consumed many different ways (web, twitter client, cell phone etc).  This gives great flexibility on how each team member decides on how he/she want to monitor the build process.  In this blog post I will show you how you can add twitter build notifications to a build process.

First you should get a twitter account so you can tell your team members what account they should follow to get the notifications.  You might want to set up your twitter account as private so you can manage who is allowed to follow.  Also this brings up a good point as you should not send any sensitive data in your build message tweet because the messages are sent across the wire and anyone can intercept them.

Next go get the Yedda Twitter C# Library.  This is a C# wrapper around the Twitter API.  It is very easy to use.  You can use the binary from the project or use the Twitter class that is part of the project.

All build processes that I have used (TFS, NANT, CCNET, and MSBUILD) allow for command line applications to be called from the build script.  So we will use the Twitter.cs class found in the Yedda C# Library in a console application to expose it's capabilities of sending twitter updates.  Go ahead and create the Console application and add the Twitter.cs class to it.  Then in the Program.cs Main method write some code to parse a few command line options to pass along to the Twitter,Update method. 

image

Example command line call to the executable:

tc -user twitterUserName -password twitterPassword -message "Build 1.4.5.1 Failed to compile"

Example tweet generated from the above command line:

image

Now all you have to do is put the new console executable in a place on your build box that is accessible by the automated build and change your build script to call it with the right message.  You can make the tweet a little more informative as to why the build failed, or you can have the build tweet at certain key points of the process so you know exactly what step the build is on.  Be creative but don't send too many messages or the team members will soon ignore all build tweets as they end up being annoying.

Possibilities for improvement

  • You could make a twitter client that monitors the build tweets and it parses the message from the build and reacts differently based on if the build failed on a compiler error or a unit test.  Maybe some static analysis failed but it isn't severe enough to grant immediate attention.  The client might attempt to grab the team members attention more if the severity of the message is high enough.
  • What about a twitter client that parses the messages and controls a traffic red light.  Green is build passed.  Red is build failed. Yellow is unit tests failed.   

TwitterBuildNotification.zip (6.46 kb)

I have blogged several times before about my involvement in building the Field Management System that runs the FIRST FRC events.  Each year I have worked very hard with 2 other engineers on trying to build the best possible experience for the volunteers that run the event, teams that participate in the event, and the audience that attends the event.  This year we wanted to extend the experience to beyond those that actually attend the event.  We wanted to have a way to announce the results of the matches as they are happening on the field.  This has been done in the past by updating an HTML web page that gets posted on the FIRST web site.  But we wanted something more that could be used by the teams in their quest for knowledge on what is happening during each event on their device of choice.

So I am very pleased to say that this years event will have twitter updates for each match as they are completed on the field.  All you have to do is follow the FRCFMS twitter account in order to get match updates from all events.  The tweets that are posted follow a specific format that should allow the teams to build really cool applications on top of the twitter data.  Here is an example tweet of our test event:

 image

As you can see in the tweet it is a little hard to read as we are jamming a bunch of information into the 140 character limitation but this should be vary easy to parse the information with a bot of some sort.

The format is defined as follows:

#FRCABC - where ABC is the Event Code.  Each event has a unique code.

TYP X - where x is P for Practice Q for qualification E for Elimination

MCH X - where X is the match number

ST X - where X is A for Autonomous T for Teloperated C for complete

TIM XXX - where XXX is the time left

RFIN XXX - where XXX is the Red Final Score

BFIN XXX - where XXX is the Blue Final Score

RED XXX YYY ZZZ - where XXX is red team 1 number, YYY is red team 2 number, ZZZ is red team 3 number

BLUE XXX YYY ZZZ - where XXX is blue team 1 number, YYY is blue team 2 number, ZZZ is blue team 3 number

RCEL X - where X is the red Super cell count

BCEL X - where X is the blue Super cell count

RROC X - where X is the red rock and red Empty Cell count

BROC X - where X is the blue rock and blue Empty Cell count

There are some cool ways you can use twitter to get the information you want for a specific event.  Hop on over to search.twitter.com and enter in the following #FRCTEST TYP Q and you will get a list of all qualifying matches for the TEST event.  When the events start this weekend you can substitute the TEST code with the event code of your choice.  The FIRST FRC Team update has a list of all the valid event codes.

You can also use the search.twitter.com with your favorite RSS reader to get updates in RSS format.

If other tweeple are tweeting about the event and using the same hashcode that the Field Management System uses then you can hop on over to #hashtags and enter in the hash code for the event and see all tweets for that event.  For example try navigating to http://www.hashtags.org/tag/frctest and you will see all the tweets for the #frctest event that we have been running to test the Field Management System.

Although for week one the match tweets will only be at the end of each match, week 2 we are thinking about upping the frequency of these tweets so that you get more of them while the match is in play.  This will make it very difficult for a human to read the tweets on a small device because they will be too many of them coming.  I would like to hear any ones thought on what the frequency of tweets should be and if they expect to be reading the tweets rather than parsing them with another tool.  Of course if you intend to read the tweets and you are only interested in the final match result you could use the search.twitter.com advanced search capabilities to only view tweets that have the status of complete.  That search would look something like this:

image

It will be really cool to see how the information we are posting is going to be used!

I ran into a strange issue today when I was trying to figure out why my TFS Build was reporting that the build was partially successful even though every test was passing.  The normal build report really did not give any good reason why it was partially successful other than the fact that it was something related to the unit tests (I am using MS Test in this case).  So I cracked open the build log and peeled through the entries.  I noticed that when the code coverage was attempting to instrument the assemblies it reported that several of the assemblies could not be located.  Then I remembered I did some refactoring and I renamed and consolidated some assemblies. 

Well that should be an easy fix all I had to do was remove these assemblies from the test run config in the Code Coverage section.  So I opened up the LocalTestRun.testrunconfig file in Visual Studio 2008 and selected the Code Coverage section to make my changes.  As soon as I did this the config editor closed down (crashed).  Wow that was weird I never saw that before.  Hmmm I wonder what it could be.  Well here is what I did to try and locate the issue.

  1. Perhaps the Test Run Config file needs to be checked out of source control for write access.  Nope that wasn't it.
  2. Well if I cant edit it in VS 2008 then I might as well try notepad.  I removed the offending assemblies using notepad in the LocalTestRun.testrunconfig.  However once I opened up the Test Run Config editor and selected the Code Coverage the editor still crashed.
  3. Perhaps I malformed the Test Run Config xml file.  So I opened it up again in notepad and the XML looked fine.  Besides if this XML was malformed I don't think the Test Run Config editor would not open at all.
  4. Consult almighty search engine.  Wow look what I found http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=391255 and it was only reported 2 days ago.

So to be sure that I got the Test Run Config file right I removed my Database project from my solution made my edits for Code Coverage in the Test Run Config editor, then added the database project back into the solution. 

After fixing the Test Run Config file my build ran successfully.