Created
November 28, 2010 03:59
-
-
Save simensen/718572 to your computer and use it in GitHub Desktop.
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/sh | |
echo | |
echo "Redmine gitolite Post Receive Hook" | |
echo | |
HOOK_URL=gitolite_hook | |
FETCH_URL=sys/fetch_changesets | |
LOG=/home/git/logs/post-receive.log | |
KEY=$(git config hooks.redmine_gitolite.key 2>/dev/null) | |
if [ -z "$KEY" ]; then | |
KEY=your_redmine_api_key | |
fi | |
REDMINE_SERVER=$(git config hooks.redmine_gitolite.server 2>/dev/null) | |
if [ -z "$REDMINE_SERVER" ]; then | |
REDMINE_SERVER=http://your.redmine.server.com | |
fi | |
REDMINE_PROJECT_ID=$(git config hooks.redmine_gitolite.projectid 2>/dev/null) | |
if [ -z "$REDMINE_PROJECT_ID" ]; then | |
REDMINE_PROJECT_ID=$GL_REPO | |
fi | |
CURL_IGNORE_SECURITY_CFG=$(git config --bool hooks.redmine_gitolite.curlignoresecurity 2>/dev/null) | |
if [ -z "$CURL_IGNORE_SECURITY_CFG" ]; then | |
CURL_IGNORE_SECURITY_CFG="false" | |
fi | |
case "$CURL_IGNORE_SECURITY_CFG" in | |
true) | |
echo "Ignoring cURL security settings." | |
CURL_IGNORE_SECURITY=" -k " | |
;; | |
false) | |
echo "cURL security settings are enabled." | |
CURL_IGNORE_SECURITY=" " | |
;; | |
esac | |
echo "Notifying Redmine (${REDMINE_SERVER}) about changes to this repo (${GL_REPO} => ${REDMINE_PROJECT_ID})" | |
echo | |
# Read from stdin | |
while read old new refname; do | |
echo "Hit the Redmine Gitolite hook for $old $new $refname" | |
echo -n "Response: " | |
curl $CURL_IGNORE_SECURITY -S -s -d "oldrev=$old&newrev=$new&refname=$refname&user=$GL_USER" "$REDMINE_SERVER/$HOOK_URL?project_id=$REDMINE_PROJECT_ID" | |
echo "" | |
echo "" | |
echo "Hit the Redmine fetch changesets URL" | |
curl -S -s $CURL_IGNORE_SECURITY "$REDMINE_SERVER/$FETCH_URL?id=$REDMINE_PROJECT_ID&key=$KEY" | |
echo "" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment