Skip to content

Instantly share code, notes, and snippets.

@edy
Last active October 9, 2015 08:07
Show Gist options
  • Save edy/3467034 to your computer and use it in GitHub Desktop.
Save edy/3467034 to your computer and use it in GitHub Desktop.
post receive hook for git
#!/bin/bash
postreceivescript=$(git config hooks.postreceivescript)
redmineid=$(git config hooks.redmineid)
url=$(git config hooks.url)
while read msg; do
echo "Sending post-receive email"
echo "$msg" | /usr/share/doc/git-core/contrib/hooks/post-receive-email
# execute custom repository script
if [ -n "$postreceivescript" ]; then
if [ -x "$postreceivescript" ]; then
echo "Executing custom post-receive script: $postreceivescript"
echo "$msg" | $postreceivescript
else
echo "Error: Could not execute (file not found): $postreceivescript"
fi
fi
# redmine update
if [ -n "$redmineid" ]; then
echo "Updating redmine"
nohup curl "http://<redmine url>/sys/fetch_changesets?key=<redmine key>&id=${redmineid}" > /dev/null 2>&1 &
fi
# hook url
if [ -n "$url" ]; then
echo "executing web hook: $url"
nohup curl $url > /dev/null 2>&1 &
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment