Yammer and SVN post-commit hooks

Written by John on October 9, 2008 – 9:32 am -

If you don't know what Yammer is, it is a twitter like communication tool for your company:

Yammer is a tool for making companies and organizations more productive through the exchange of short frequent answers to one simple question: “What are you working on?”

Whats nice about Yammer is it is an internal tool that you can quickly communicate with everyone, well anyone listening, in your company. Answers to questions come quickly and from the appropriate party without much effort on either end and notifications to everyone are a snap.

The notifications is what got me thinking about Subversion and post-commit hooks. Subversion provides hooks that allow you to trigger scripts based on a repository event. So, I set up a script that retrieves information about the latest commit to the repository formats an email which is sent to Yammer and published. Now, when someone commits to the repository, everyone is automatically notified without the developer having to write an email and send it to everyone that needs to know about it.

Another unforeseen benefit of this system is that everyone has gotten much better at their SVN comments for their commit. I would imagine this is because they get instant feedback about inadequate comments when everyone see it in Yammer.

On to the resources - SVN hooks are pretty easy to implement and provided by default. They reside in each repository you create in a 'hooks' directory {SVN_ROOT}/{REPOSITORY}/hooks. There is a provided template for each type of hook that SVN supports. The script can be any type of script (shell scripts, Python scripts etc), it just needs to have the same name as the supplied template file. For our Yammer script I dusted off the .bat script skills to retrieve the commit and send an email. To send the email I downloaded blat to handle sending the email to Yammer. Finally we create an email for out SVN user and a yammer account using the svn user email.

So here is the list of what we have so far:

  • SVN Repositoy and access to the hooks directory
  • Email address for the SVN user
  • Yammer account using the SVN user's email address
  • Some way to send an email (Blat)
  • SVN post-commit hook script (post-commit.bat)

Now on to the contents of the script - The post commit hook receives 2 arguments, the name of the repository and the revision. The script uses svnlook, the repository name and revision to retrieve the details (message and author) of the commit. Then usign the commit details the script creates a text file that Blat uses as the email body and sends the email to Yammer.

Here is the actual script (names have been changed to protect the innocent):

CODE:
  1. @echo off
  2.  
  3. :::::::::::::::::::::::::::::::::::::::::::::::::::::
  4. ::: ARGUMENTS :::::::::::::::::::::::::::::::::::::::
  5. SET REPOS=%1
  6. SET REV=%2
  7.  
  8. :::::::::::::::::::::::::::::::::::::::::::::::::::::
  9. ::: GENERAL INFO ::::::::::::::::::::::::::::::::::::
  10. SET DIR=%REPOS%/hooks
  11. SET MESSAGE_FILE=%DIR%/message.txt
  12.  
  13. :::::::::::::::::::::::::::::::::::::::::::::::::::::
  14. ::: SVN INFO ::::::::::::::::::::::::::::::::::::::::
  15. SET DIR=%REPOS%/hooks
  16. SET REPO_PATH=file:///%REPOS%
  17.  
  18. ::: Get the author ::::::::::::::::::::::::::::::::::
  19. For /F "Tokens=*" %%I in ('svnlook author %REPOS% -r %REV%') Do Set author=%%I
  20.  
  21. ::: Get the log messsage ::::::::::::::::::::::::::::::::::
  22. For /F "Tokens=*" %%I in ('svnlook log %REPOS% -r %REV%') Do Set log=%%I
  23.  
  24. ::: Set the message body ::::::::::::::::::::::::::::::::::
  25. ECHO Commit - rev %REV% (#%author%): '%log%' - %REPOS%> %MESSAGE_FILE%
  26.  
  27. :::::::::::::::::::::::::::::::::::::::::::::::::::::
  28. ::: EMAIL INFO ::::::::::::::::::::::::::::::::::::::
  29.  
  30. set to=-to yammer@yammer.com
  31.  
  32. set subj=-s "SVN Commit (Revision %REV%)"
  33.  
  34. set server=-server mail.domain.com
  35.  
  36. set debug=-debug -log blat.log -timestamp
  37.  
  38. set auth=-u email@domain.com -pw yourpasswordhere
  39.  
  40. set from=-f email@domain.com
  41.  
  42. :::::::::::::::::::::::::::::::::::::::::::::::::::::
  43. ::: SEND THE EMAIL ::::::::::::::::::::::::::::::::::
  44. C:/pathtoyourrepos/_tools/blat/blat %MESSAGE_FILE% %server% %to% %from% %subj% %auth% %debug%

Or you can download the script:

http://john.realeyes.com/wp-content/plugins/downloads-manager/img/icons/default.gif download: post-commit.bat.zip (1.03KB)
added: 09/10/2008
clicks: 56
description: SVN post-commit hook .bat script to send an email to yammer.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Netvouz
  • description
  • ThisNext
  • MisterWong
  • Wists
  • Facebook
  • StumbleUpon
  • Technorati
  • YahooMyWeb

ANT + Growl notifications = Happy Coder

September 15, 2008 – 8:57 am

We have a bunch of projects around here that we build with ANT. One of the biggest gripes with ANT builds and Flex is the amount of time it can ...

Mozilla Ubiquity - Useful and fun

August 27, 2008 – 10:00 am

So i've been checking out Ubiquity and playing with it a bit. Even in its "early, rough" state, it is fun stuff to play with and definitely useful! I even had ...

Some good things in life are free!

July 22, 2008 – 2:50 pm

So I just snagged the Wordpress iPhone app. And wanted to we how it worked. Yay. Now I can blog from just about anywhere - even the bathroom (not that ...

Mate & Swiz - Other Flex Frameworks

July 22, 2008 – 11:23 am

Jun Heider just pointed me to the Swiz Framework. Swiz is a framework for Adobe Flex that aims to bring complete simplicity to RIA development. Swiz provides Inversion of Control, event ...

Status Update - what I’m doing and have done latley

June 30, 2008 – 9:30 am

Its been a crazy busy summer so far! Here is quick status of the stuff that I've been doing. Work Lots of ActionScript 2 - oh yay! But, it is still needed ...

Links: SQLLite, Peddle Pushers & Music Mixing

May 29, 2008 – 10:15 am

SQLite-manager A very lightweight firefox extension (originally) to manage all your sqlite databases. This extension will be useful to developers who want to create and play with sqlite databases. Thanks Jun! Clear ...

WTF is JavaFX?!? (book review)

May 29, 2008 – 10:00 am

I didn't really know anything about JavaFX until I picked up this book. Now not only do I know what it is, I can use it too. If you're looking ...

Looking to learn CSS? (book review)

May 24, 2008 – 10:43 am

If you're looking to jump into CSS or maybe just refresh your skills - then this is a good book to pick up! Book Description: "This book teaches you everything you ...

Identifying Multiple Screens with Adobe AIR

May 7, 2008 – 11:52 am

While working on a presentation about Native Windows & Adobe AIR I ran into the Screen class. The screen object provides information about the display screens available to an application ...

Find entries :

Want to subscribe?

  Subscribe in a reader or,
Subscribe via email:

About me

I'm a senior developer at RealEyes Media, Adobe Certified Instructor and Adobe Certified Professional. Here you'll get my ideas and experience Flex, Flash, ColdFusion and related technologies as well as some generally off the wall stuff.