Skip to content

Instantly share code, notes, and snippets.

@ilaborie
Created July 23, 2013 15:08
Show Gist options
  • Save ilaborie/6063105 to your computer and use it in GitHub Desktop.
Save ilaborie/6063105 to your computer and use it in GitHub Desktop.
Git post-commit hook for: auto-push to jenkins + auto backup
#!/bin/sh
# Backup
git ls-remote backup --quiet
if test $? = 0;
then
git push backup --force --all --quiet
echo "...Backuped"
else
echo "No Backup repository => Skip backup"
fi
# Push to jenkins if master branch
if [[ `git symbolic-ref HEAD` == "refs/heads/master" ]]
then
echo "Auto Pushing 'jenkins' branch to Jenkins server..."
git push jenkins jenkins --quiet
fi
# Push to jenkins if master branch
if [[ `git symbolic-ref HEAD` == "refs/heads/jenkins" ]]
then
echo "Auto Pushing 'master' branch to Jenkins server..."
git push jenkins jenkins --quiet
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment