Git后接收钩不工作 [英] Git post-receive hook not working

查看:174
本文介绍了Git后接收钩不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的设置是一个Windows XAMPP服务器,启用cURL,并安装了Git和Hudson。 Hudson每分钟调查Git以查找更改,如果找到它们,它会创建一个构建。我使用这个构建作为我的测试服务器。这工作正常。



我想在我的中央远程仓库设置一个后接收钩子,运行Hudson的强制构建函数。



我在我的中央Git仓库的hooks目录中创建了一个名为post-receive的后接收文件,它是从开发人员的本地分支推送的。他们每个都在中央存储库上推送到自己的分支。



当我打开一个shell到远程服务器并运行远程服务器时, post-receive在hooks文件夹中,它运行。



也许我没有解释这个问题,但是这是怎么回事?了解Git。



后接收代码是两行:

 #!/ bin / sh 
curl http://myserver.com:8080/hudson/job/myjobname/build?token=mytoken

再次,当我打开一个shell并运行它,它的工作原理,但是当有人推动它,没有任何反应,直到一分钟或更少的时间,Hudson意识到Git更改,然后它构建。



我很高兴澄清如果需要。非常感谢任何帮助。



编辑:玩过它后,我觉得也许后接收不执行,因为refs没有更新的东西? git文档说


在所有的更新完成之后,它在远程仓库上执行一次。


这是否意味着如果没有更新,它将不会执行?



这是我的过程:
在本地进行编辑。
提交修改。
从我的HEAD推送到远程分支叫'mybranch'(不是主分支,签出)
这是我想要执行钩子的点。

$ b所有这些答案都很有用,但结果是我需要我的PATH变量中的bin目录下的git。我只有cmd目录。添加 c:\my_path_to_git\git\bin 到PATH,它工作正常。我发现这个答案通过尝试和错误,并查看apache错误日志。感谢大家的帮助!


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.

解决方案

All of these answers are useful, but it turns out I needed the "bin" directory of git in my PATH variable. I had the "cmd" directory only. Added c:\my_path_to_git\git\bin to PATH and it works fine. I found this answer by trial and error and looking at the apache error log. Thank you all for your help!

这篇关于Git后接收钩不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆