My setup is a windows XAMPP server, with cURL enabled, and Git and Hudson installed. Hudson polls Git every minute to look for changes, and if it finds them, it creates a build. I use this build as my testing server. This works fine.
I would like to set up a post-receive hook on my central remote repository that runs the force build function of Hudson.
I've created a post-receive file called "post-receive" in the hooks directory in my central Git repository, the one that is pushed to from the developers' local branches. They each push to their own branch on the central repository. I want to run the post-receive build immediately after every push, instead of having Hudson poll Git every minute.
When I open a shell to the remote server and run "post-receive" in the hooks folder, it runs. It just isn't being called when people push to it from their local repository copies to the central one.
Maybe I'm not explaining this right, but it's how I understand Git.
The post-receive code is two lines:
#!/bin/sh
curl http://myserver.com:8080/hudson/job/myjobname/build?token=mytoken
Again, when I open a shell and run this, it works, but when someone pushes to it, nothing happens, until a minute or less goes by, Hudson realizes that Git was changed, and then it builds.
I am happy to clarify if need be. Any help is greatly appreciated.
EDIT: After playing around with it, I feel like maybe post-receive isn't executing because refs aren't being updated of something? The git documentation says
It executes on the remote repository once after all the refs have been updated.
Does this mean if nothing updates, it won't execute? And if so, I'm pretty sure things are updating anyway so it shouldn't apply.
Here's my process: Make edits locally. Commit edits. Push from my HEAD to the remote branch called 'mybranch' (not the master branch, which is checked out) This is the point at which I want my hook to execute.
Please check whether your file has executable rights. Otherwise it can not be executed.
Something like rwxr-xr-x
should be sufficient.
You can add the missing bit with
$ chmod +x /path/to/post-receive
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