Reputation: 1572
I'm working on local server with Jenkins and my task now is to trigger testing script after each git push.
I tried to do this with post-commit hook, which worked as expected but it ran tests before actual changes were made (pushed to repo). Well, its post-commit, so that's expected.
So I decided to use some kind of post-push and found post-receive hook, but its not working at all. Running sh post-receive
does what I want, chmod +x
done. What am I doing wrong? Should I use another hook?
Upvotes: 2
Views: 389
Reputation: 1323883
A post-receive hook is a server-side hook, run when a Git hosting server received a push.
It is generally set in a bare repo:
myBareRepo.git/hooks/post-receive
If your Jenkins monitors your repo, you could:
set your Jenkins job to monitor a bare repo instead:
git clone --bare myRepo myRepo.git
add the post-receive hook in that bare repo instead
pushing from your repo to this bare repo
cd myRepo
git remote add origin ../myRepo.git
git push -u origin master
Upvotes: 1