English 中文(简体)
git hooks and how they work
原标题:
  • 时间:2009-11-11 18:47:24
  •  标签:
  • git
  • hook

So I m trying to get hudson to build with a post-receive hook. In my local git repo I set post-receive.sample to just post-receive, chmod 755 and added in the line:

/usr/bin/curl -u user:secret http://localhost:8080/hudson/job/MyJob/build?token=secondsecret

If I force a build, hudson updates the code, but here s what I don t understand, the hooks in that repo DON t have the .sample after them like they do locally, and the post-receive in the hudson repo doesn t have that line of code above. What s going on here and how are hooks integrated into the whole git process? Do I need to be changing this hook on the remote repo? I would have thought it was enough to do it locally and push so anyone fetching from that repo get the new hooks. I can t understand how another user s repo would have different hooks.

最佳回答

You basically have two options:

  1. Place the post-receive hook on the server and let the server run curl.
  2. Place a post-commit hook on your local repo and let your local box run curl.

As your build job will probably fetch the code to build from the repo on the server, only option 1. makes sense. In case 2., the build job would probably have to fetch the code from your local box, and that is probably not what you want.

You cannot place hooks onto the server using git push. You (or someone with the appropriate permissions) needs to do that by manually logging into server and modifying the hook script files locally.

问题回答

Hooks are not shared through the repository. You need to install the hook at the remote side.





相关问题
git confusion - cloning a repo is returning a past version

Im having some confusion with my git usage. I cloned a repo from one comp to the other, and the new clone is the state of the original that was active some time ago. So its cloning a past version. ...

Appropriate strategy for tagging and hotfixing with git

I was wondering if the strategy I m using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate. For tagging I just tag a commit of the master ...

Tips on upgrading CVS to git/hg?

We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...

Using Git in a TFS shop

Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...

热门标签