Skip to content

Instantly share code, notes, and snippets.

@bartfastiel
Last active April 18, 2017 14:08
Show Gist options
  • Save bartfastiel/625f1550863aa5fde7faa9b523e5b5f5 to your computer and use it in GitHub Desktop.
Save bartfastiel/625f1550863aa5fde7faa9b523e5b5f5 to your computer and use it in GitHub Desktop.
#!/bin/sh
# stop any running old instances
cd ../latest
./stop.sh
cd $OLDPWD
# calculate state
CURRENT_TIMESTAMP=$(date "+%Y%m%d-%H%M%S")
if [ $# -eq 0 ]; then
GIT_STATUS=$(git describe --match=NeVeRmAtCh --always --abbrev=40 --dirty)
GIT_COMMIT=$(sed 's/-dirty//' <<< "$GIT_STATUS")
SUFFIX=
else
GIT_STATUS=$(git rev-parse $1)
GIT_COMMIT=$1
SUFFIX=-${1//\//_}
fi
SONARQUBE_DIR=sonarqube-$CURRENT_TIMESTAMP-$GIT_STATUS$SUFFIX
# prepare parallel directory
echo creating $SONARQUBE_DIR
mkdir ../$SONARQUBE_DIR
git archive $GIT_COMMIT | tar -x -C ../$SONARQUBE_DIR
# wait for confirmation
echo
read -n1 -r -p "Press any key to start compilation and start sonarqube..." key
# compile and start
rm ../latest
ln -s $SONARQUBE_DIR ../latest
cd ../$SONARQUBE_DIR
./start.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment