Skip to content

Instantly share code, notes, and snippets.

@yu1ec
Forked from ilaborie/post-commit
Created January 29, 2018 14:08
Show Gist options
  • Save yu1ec/eb416642ead5e2d1abd2a4b9321b831a to your computer and use it in GitHub Desktop.
Save yu1ec/eb416642ead5e2d1abd2a4b9321b831a 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