Skip to content

Instantly share code, notes, and snippets.

@magopian
Last active August 27, 2019 04:32
Show Gist options
  • Save magopian/6128849 to your computer and use it in GitHub Desktop.
Save magopian/6128849 to your computer and use it in GitHub Desktop.
Local git mirror of github used by private Jenkins
So I've installed a dead simple backup, in /home/USER/git_backup/:
git clone --mirror [email protected]:USER/PROJECT.git
update.sh (launched every 5 minutes by cron):
#/bin/sh
cd /home/USER/git_backup/PROJECT.git
LINES=`git remote update 2>&1 | wc -l`
if [ $LINES -eq 1 ]; then
# only one line "Fetching origin"?
echo "Project didn't changed"
else
echo "Project changed, notify jenkins builds"
curl http://JENKINS:8080/git/[email protected]:USER/PROJECT.git
fi
This keeps a perfect copy (mirror) of the PROJECT github repository, and if there's a change when doing the "git remote update", jenkins is notified, and it'll then poll github to check if it should run the builds related to the url provided.
@jsoref
Copy link

jsoref commented Aug 27, 2019

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