Make your buildserver talk

Jenkins talking Have you ever started a shell script which takes a while and you keep monitoring that window because you really need those results? If you are working on a Mac, you can use the Mac's power of speech to tell you a command is finished. Here's how:

[sourcecode language="bash" gutter="false"] ./yourreallyslowbuild.sh; say "really long build is finished" [/sourcecode]

With a little curl and shell scripting magic, I told my Mac to constantly monitor our Jenkins buildserver, and bug everybody in the office when the hourly build is failing:

[sourcecode language="bash" gutter="false"] #!/bin/sh

Configuration

jenkinsurl=http://my.jenkins.server/jenkins voice=Vicki

The function that does the trick

fnReportFailure() { job=${1} message=${2} result=curl -s \ ${jenkinsurl}/job/${job}/lastBuild/api/xml?xpath=/*/result/text()

if  [ "${result}" == "XPath /*/result didn't match" ]
|| [ "${result}" == "ABORTED" ]; then # ignore aborted or in-progress build. Ignore. return 0 elif [ "${result}" != "SUCCESS" ]; then echo date ${job} : ${result} say -v "${voice}" "${message}" fi }

Loop over all projects and shout out problems

clear echo echo "Monitoring ${jenkinsurl}" echo printf "===== "

while [ true ]; do

Add as many jobs as you want here:

fnReportFailure "hourly_java_job" "The hourly java job is unstable." fnReportFailure "hourly_deploy_job" "The hourly deploy failed."

Tell the time and sleep a little

now=date +%H:%M:%S printf "\b\b\b\b\b\b\b\b\b${now} " sleep 60 done [/sourcecode]

This script talks with the "Vicky" voice, because I let "Alex" read my iChat messages to me. Of course, the "Bad News" and "Zarvox" voices may be even more "motivating" to quickly fix the build. Now go and keep your eyes on youtube... err I mean your code.

Enjoy.