I have git running on a local Windows PC and everything is working perfectly; I have Jenkins and Phing working to automate my build and test processes, however the final step is to automatically kick off the build once a commit is made in git.
I have tried adding post-commit to my local repo's .git/hooks directory with the following:
curl http://localhost:8198/git/notifyCommit?url=c:\scm\myProject
If I run this command directly from the command line Jenkins kicks off the job fine, however when I push a commit it does not fire.
Additionally I have tried adding the script at https://github.com/MestreLion/git-tools/blob/master/git-restore-mtime to the hooks directory in the main repo named post-checkout so that I can add the commit time as the file modified time when cloned. This is also not firing.
Do I need to do something specifically in git or my repo to allow hooks to fire? If not, is there anywhere in particular I can look to start troubleshooting?
Do I need to do something specifically in git or my repo to allow hooks to fire?
Mainly:
chmod 775 .git/hooks/post-commit, which isn't actually needed on Windows)curl' is in the %PATH% (which is the case if your <c:\path\to\git>\bin is in said path)#!/bin/sh at the beginning of your post-commit script (since it will be executed by the msys bash).sh or .bat)The Op mentions an issue with missing quotes around the curl argument.
This is consistent with the fact that it is called in an msys bash session, and shell quoting rules apply.
I would make sure the '\' character isn't interpreted as well.
See "Which quoting method protects which characters?":
Double quotes (
"...") protect everything except double quotes, backslashes, dollar signs, and backquotes, until the next double quote.
A backslash can be used to protect",\,$, or within double quotes.
A backslash-newline pair disappears completely; a backslash that does not precede",\,$, , or newline is taken literally.
In your case, I would use:
curl "http://localhost:8198/git/notifyCommit?url=c:\\scm\\myProject"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With