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 smooter.

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

12 comments on “Making the Atlassian SDK growl

  1. Sherif Mansour says:

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

  2. Sherif Mansour says:

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

  3. Ajay Goel says:

    That’s pretty cool buddy!

    1. David says:

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

      1. Ajay Goel says:

        Very creative indeed!

  4. Ajay Goel says:

    That’s pretty cool buddy!

    1. David says:

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

  5. Mike Cannon-Brookes says:

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

    1. David says:

      Absolutely, that would be great.

  6. Mike Cannon-Brookes says:

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

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

WP-SpamFree by Pole Position Marketing