Skip to content

Instantly share code, notes, and snippets.

Created May 16, 2012 08:12
Show Gist options
  • Save dgageot/2708610 to your computer and use it in GitHub Desktop.
Save dgageot/2708610 to your computer and use it in GitHub Desktop.
Unbreakeable build
function alert_user {
echo "${1}"
which -s growlnotify && growlnotify `basename $0` -m "${1}"
function exit_ko {
alert_user "${1}"; exit 1
function exit_ok {
alert_user "${1}"; exit 0
REMOTE_URL=$(git remote show -n ${REMOTE} | awk '/Fetch/ {print $3}')
BRANCH=$(git symbolic-ref -q HEAD)
# Git black magic to pull rebase even with uncommited work in progress
git fetch ${REMOTE}
git add -A; git ls-files --deleted -z | xargs -0 -I {} git rm {}; git commit -m "wip"
git rebase ${REMOTE}/${BRANCH}
if [ "$?" -ne 0 ]; then
git rebase --abort
git log -n 1 | grep -q -c "wip" && git reset HEAD~1
exit_ko "Unable to rebase. please pull or rebase and fix conflicts manually."
git log -n 1 | grep -q -c "wip" && git reset HEAD~1
# Private build
rm -Rf ../privatebuild
git clone -slb "${BRANCH}" . ../privatebuild
cd ../privatebuild
# Build with maven
mvn -T4 install
if [ $? -ne 0 ]; then
exit_ko "Unable to build"
# Push
git push ${REMOTE_URL} ${BRANCH}
if [ $? -ne 0 ]; then
exit_ko "Unable to push"
# Update working directory
cd ${LOCATION} && git fetch ${REMOTE}
exit_ok "Yet another successful build!"
Copy link

I think you are using the same local maven repository for the "private build".
How can you make sure previous local builds did not change the state of the local maven repository ?
Maybe some dependencies have been built on the developer laptop before the private build; that would mean the private build is biased.
On the other hand, a separate CI server, wiping its local maven repository before building, would only rely on the reactor artifacts and nexus.
Maybe your script should wipe the local maven repo or use another local repo (using a different settings.xml) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment