Created
September 15, 2011 08:24
-
-
Save emmanuelbernard/1218818 to your computer and use it in GitHub Desktop.
Run the command on a git clone (using current branch)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Clones your existing repo and run the subsequent command off this clone | |
# Tests are run on the the current branch at the time of cloning | |
# | |
# Note that you can work on the next bug while this is going on as | |
# tests are run off a cloned repo. | |
# | |
# $ remote.sh mvn clean install | |
# runs 'mvn clean install' | |
# | |
# A notification is sent upon build completion if your OS supports it: | |
# - on Mac OS, install Growl and grownnotifier | |
# - on Linux, install send-notify | |
# | |
# Many thanks to David Gageot (http://blog.javabien.net) for the inspiration and optimization of this script. | |
# | |
# Released under the WTFPL license version 2 http://sam.zoy.org/wtfpl/ | |
# | |
# Copyright (c) 2010 David Gageot | |
# Copyright (c) 2010-2011 Emmanuel Bernard | |
# Copyright (c) 2011 Sanne Grinovero | |
#the cloned repo will live in ../DIRECTORY_ROOT/REPO_DIRECTORY | |
DIRECTORY_ROOT="../privatebuild/" | |
#get the lastest part of the directory name | |
IFS="/" | |
SPLIT_DIR=(`pwd`) | |
SIZE=${#SPLIT_DIR[@]} | |
let LAST_INDEX=$SIZE-1 | |
DIRECTORY_SUFFIX=${SPLIT_DIR[$LAST_INDEX]} | |
IFS="" | |
DIRECTORY="${DIRECTORY_ROOT}${DIRECTORY_SUFFIX}" | |
BRANCH=`git branch | grep "*" | awk '{print $NF}'` | |
#fresh clone | |
rm -Rf $DIRECTORY | |
git clone -slb "$BRANCH" . $DIRECTORY | |
cd $DIRECTORY | |
echo "" | |
echo "***** Working on branch $BRANCH *****" | |
echo "" | |
say() { | |
if [ `uname -s` == "Darwin" ]; then | |
# On Mac OS, notify via Growl | |
which -s growlnotify && growlnotify --name Remote --sticky --message "'$CMD_DISPLAY' on branch $BRANCH - $RESULT" | |
fi | |
if [ `uname -s` == "Linux" ]; then | |
# On Linux, notify via notify-send | |
which notify-send && notify-send "'$CMD_DISPLAY' on branch $BRANCH" "$RESULT" | |
fi | |
} | |
if [[ $# -eq 0 ]]; then | |
echo "Usage remote.sh <command to run>" | |
else | |
CMD_DISPLAY="$@" | |
fi | |
$@ | |
if [ $? -eq 0 ]; then | |
RESULT="SUCCESS" | |
echo $RESULT | |
say | |
else | |
RESULT="FAILURE" | |
echo $RESULT | |
say | |
exit $? | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For the record, I do the same thing with Jenkins. I have a whole bunch of jobs configured, but also one which build my current branch.
Two things are important there
The right repo url. I use
A way to switch the git clone to the right branch (the one which is active in your checkout). I do this via a Shell Command build step
With this setup I can also build my current branch on the press on the button while I still can continue working. On top of this I get a build history, logs, etc