git post-receive 钩子,抓取提交消息并回发到 URL
我们正在使用一个票务系统,当开发人员将更改推送到服务器时,我希望自动更新该系统。为了更新它,我只需要提供一个带有提交消息的特定 URL 作为 GET 变量。然后,被调用的页面将记录此更改。我知道我的方法是使用 hooks,但我不熟悉 Bash 也不熟悉 Perl所以这是相当有挑战性的。
我想实现这一点:
- 开发人员推送到服务器
post-receive
挂钩运行并检查哪些不同的提交是新的(因为一次推送中可能有多个)- 它循环遍历它们,并且对于每个提交,它将打开一个带有提交消息的 URL(
curl http://server.com/logthis.asp?msg=Here_goes_the_commit_message
,类似的东西)
We are using a ticketing system that I want to automatically update as developers push their changes to the server. In order to update it, I only need to provide a specific URL with the commit message as a GET variable. The page being called will then log this change. I know my way to go is with hooks, but I am not familiar with Bash nor Perl so it is quite challenging.
I want to achieve this:
- Developer PUSHes to the server
post-receive
hook runs and checks which different commits are new (because there could be several in one push)- It loops through them, and for each commit, it will open a URL with the commit message (
curl http://server.com/logthis.asp?msg=Here_goes_the_commit_message
, something like that)
That's it. Although I have checked out some samples related to this kind of idea, none do exactly this. How could this be done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
主要的 PITA 是隔离新修订的正确列表,这是我从 /usr/share/doc/git/contrib/hooks/post-receive-email(show_new_revisions) 借来的。
The main PITA is to isolate the correct list of new revisions, which I borrowed from /usr/share/doc/git/contrib/hooks/post-receive-email(show_new_revisions).