My current project has a neat trick we picked up where the build has a red or green banner at the end when you run it locally to give good feedback about the build status. I’m not sure who originated it, but thanks!
I just had to tweak it a bit to get it working on OS X so I thought I would document the trick here.
run.sh - OS X
CMD=”./tools/ant/bin/ant -lib ./asl/lib/jdepend $@” echo “Running command [${CMD}] …” $CMD if [ “$?” -ne 0 ]; then echo -e “`tput setab 1` `cat ./ci/failed.txt` `tput setab 0`” exit 1 else echo -e “`tput setab 2` `cat ./ci/passed.txt` `tput setab 0`” exit 0 fi
This assumes you have two supporting files ./ci/passed.txt
and ./ci/failed.txt
which contain the message. You can generate messages to your taste here.
I have provided the files in this example here :
It has also been run under Ubuntu where the following works (it didnt work on OS X which is why I adapted it), but the tput
should also work on Ubuntu. I’ve not explicitly tested this one!
if [ “$?” -ne 0 ]; then echo -e “\E[30;41m” cat ./ci/failed.txt echo -e “\E[0m” exit 1 else echo -e “\E[30;42m” cat ./ci/passed.txt echo -e “\E[0m” exit 0 fi
Under windows you can actually make the entire screen of the terminal change color:
run.bat - WINDOWS
CALL tools\ant\bin\ant %* IF ERRORLEVEL 1 GOTO RedBuild IF ERRORLEVEL 0 GOTO GreenBuild :RedBuild color 4F GOTO TheEnd :GreenBuild color 2F :TheEnd PAUSE color 07