Created
February 2, 2014 16:13
-
-
Save pcholakov/8770648 to your computer and use it in GitHub Desktop.
Gitolite post-receive hook to trigger builds of Jenkins / Git jobs
This file contains 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 | |
# Gitolite [https://github.com/sitaramc/gitolite] | |
# Jenkins Git Plugin [https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin] | |
# GL_REPO will contain the short relative path of the repository being pushed to, e.g. "projects/component-1", so transform it into the Git URL format that your Jenkins build jobs follow: | |
[email protected]:$GL_REPO | |
# Jenkins Git plugin notification URL -- update host as appropriate: | |
TRIGGER_URL=http://jenkins.example.com:8080/git/notifyCommit?url=$REPOSITORY_URL | |
# You shouldn't need to modify anything beyond this line. | |
while read oldrev newrev ref; do | |
if [[ $ref == refs/heads/* ]]; then | |
branch=${ref:11} | |
echo -n "Notifying Jenkins of changes to $REPOSITORY_URL branch=$branch commit=$newrev... " | |
curl -m 5 --silent "$TRIGGER_URL&branches=$branch" || echo Failed to notify Jenkins | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment