DelayedBuildTask

A few days ago a fellow co-worker asked me if I could create a simple build task that would allow anyone on their team the opportunity to cancel a build, once it has been queued, before the build actually did anything.  The idea was simple:

  1. A new build gets queued.
  2. The build sends out an e-mail notification (via a custom task) informing the recipients that a new build has been queued.  The e-mail message also has a link that, when clicked, will cancel the build.
  3. The build waits a pre-determined amount of time (e.g. 5 minutes) giving the e-mail recipients a chance to cancel the build before it continues.
  4. If the build is not canceled, the build will proceed as usual once the delay has expired.

The driving reason behind this request was to allow any active testing to continue without being interrupted by a new build – i.e. the testers have the ability to cancel a build.

Building the custom task was pretty simple – it basically just sends out an e-mail message (based on a customizable HTML template) and then waits for the specified number of seconds (the default is 300 seconds).

The more interesting piece of the puzzle was creating a simple, one-page web site that, when called, will cancel a build.  The web page takes the build URI as its only parameter and utilizes the Team Foundation Server web services API to cancel the build.

All in all it worked out nicely.  If this sounds like something that may benefit your team, you can check it out on the MSDN Code Gallery here.  The source code as well as the binaries are available for download.

The next challenge (that was presented to me today) is to also include a link in the e-mail notification message that, when clicked, will instruct the build to continue immediately.  This one will take a little more thought…

Click here for more information on the DelayedBuildTask.

ContactUs.com

DelayedBuildTask

by Jeff Bramwell time to read: 1 min
0