Last active
October 9, 2015 08:07
-
-
Save edy/3467034 to your computer and use it in GitHub Desktop.
post receive hook for git
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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