Making the Atlassian SDK growl

Growling Polar Bear

When writing plugins using the Atlassian SDK, sometimes the builds take a little while and you go off doing other things. Maybe you’ll get diverted and lose a few minutes.

It would be nice to have some kind of feedback/notification to let you know when the build is a success, fails or just when Tomcat is finally up and running.

On OS X, Growl is my first choice for notifications, so this post shows you how to hook together the Atlassian SDK (well, maven really) with Growl

You will need:

Install all of the above.

The Atlassian SDK acts as a wrapper for maven functionality. It uses a copy of maven 2.1.0 located at:

/path/to/atlassian-plugin-sdk-3.x/apache-maven/bin/mvn

This path appears to be hard coded into a lot of the atlas- prefixed commands, so we have to get a bit hacky and move the original mvn file elsewhere and swap in a new mvn wrapper command.

cd /path/to/atlassian-plugin-sdk-3.x/apache-maven/bin/
mv mvn mvn.DIST

The new mvn file should look something like this:

#!/bin/bash

# See: http://blank.jasonwhaley.com/2009/02/growl-maven-integration.html

mvn.DIST $* | awk '
{
print;
if($0 ~ ".*BUILD ERROR.*")       system( "echo "Build failed : (" | growlnotify "Maven" --name maven --image /Users/david/Pictures/mvn-growl/fail.png > /dev/null 2>&1"  )
if($0 ~ ".*BUILD SUCCESSFUL.*")  system( "echo "Build completed successfully : D" | growlnotify "Maven" --name maven --image /Users/david/Pictures/mvn-growl/success.png > /dev/null 2>&1" )
if($0 ~ ".*CTRL-C.*")            system( "echo "localhost is now available : D" | growlnotify "Maven" --name maven --image /Users/david/Pictures/mvn-growl/atlassian-charlie.png > /dev/null 2>&1" )
} 
END {
}'

Note that we’ve got some hard coded image paths here. Store them wherever suits best and update the mvn script.

Add execute permissions

chmod +x mvn

That’s about it really.

Next time you successfully build from maven, you should get this:

A build failure should give this:

When you type atlas-run and Tomcat is ready, you should get this:

I know, this is not exactly a life changer, but it is a really handy way to get some feedback on build progress — particularly for when localhost is ready.

If you have a more elegant solution, let me know.

Note:

Here are the icons used:



David is a senior developer and solutions architect at AppFusions based in Nottingham, England.

AppFusions
AppFusions solves mixed-technology integration problems. We bring engineering and business workflows together, you can work better, faster and smoother.

AppFusions is headquartered in San Francisco, California and works with enterprise vendors and partners such as IBM, Jive, Egnyte, DropBox, Box and Atlassian.

  • Sherif Mansour

    Love your work, Mr Simpson! Will be sure to use this on the next FedEx!

    • http://davidsimpson.me/ David

      You’re so kind :)

  • Sherif Mansour

    Love your work, Mr Simpson! Will be sure to use this on the next FedEx!

    • http://davidsimpson.me/ David

      You’re so kind :)

  • http://www.appfire.com Ajay Goel

    That’s pretty cool buddy!

    • http://davidsimpson.me/ David

      Yes, this started me thinking “me too”. It’s a bit tatty moving the mvn file though.

      • http://www.appfire.com Ajay Goel

        Very creative indeed!

  • http://www.appfire.com Ajay Goel

    That’s pretty cool buddy!

    • http://davidsimpson.me/ David

      Yes, this started me thinking “me too”. It’s a bit tatty moving the mvn file though.

  • Mike Cannon-Brookes

    Badass mate. I love it. We should roll this into the standard SDK somehow!

    • http://davidsimpson.me/ David

      Absolutely, that would be great.

  • Mike Cannon-Brookes

    Badass mate. I love it. We should roll this into the standard SDK somehow!