创建一个 BitBucket git commit 钩子?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9107320/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Create a BitBucket git commit hook?
提问by crockpotveggies
I just ported over a repo from GitHub to BitBucket. Although it does many of necessities, I'm finding it surprisingly difficult to find documentation for creating a git commit hook.
我刚刚将一个 repo 从 GitHub 移植到 BitBucket。尽管它有许多必需品,但我发现很难找到用于创建 git commit hook 的文档。
Originally I had a ruby app on a CentOS server that was triggered by a GitHub hook. Does anyone know how to achieve the same in the BitBucket environment?
最初我在 CentOS 服务器上有一个由 GitHub 挂钩触发的 ruby 应用程序。有谁知道如何在 BitBucket 环境中实现相同的目标?
Thanks!
谢谢!
Edit:here's what the ruby app simply looks like if it helps:
编辑:这是 ruby 应用程序的外观,如果有帮助的话:
post '/' do
`rm -rf repofolder`
`git clone https://[email protected]/user/repo.git`
`sh fast_deploy.sh`
end
采纳答案by crockpotveggies
I was able to find a solution. Although John Percival's answer is right, no current support for Ruby, the notification mechanism works.
我能够找到解决方案。尽管 John Percival 的回答是正确的,目前不支持 Ruby,但通知机制有效。
The code for the Ruby app is in the question. Notice how it looks for a post via post '/' do
. I was able to find support to send a POST to a URL in this neat find here: http://read-the-docs.readthedocs.org/en/latest/webhooks.html
Ruby 应用程序的代码在问题中。请注意它如何通过post '/' do
. 我在这里找到了将 POST 发送到 URL 的支持:http: //read-the-docs.readthedocs.org/en/latest/webhooks.html
Given that info, I was able to create a POST hook in BitBucket via:
鉴于这些信息,我能够通过以下方式在 BitBucket 中创建一个 POST 钩子:
- Go to repo "admin" tab
- Select "services"
- Create a POST service to a special port on my URL
http://server.com:4567/
- 转到回购“管理员”选项卡
- 选择“服务”
- 为我的 URL 上的特殊端口创建一个 POST 服务
http://server.com:4567/
回答by John Percival Hackworth
Take a look at https://confluence.atlassian.com/display/BITBUCKET/Write+brokers+%28hooks%29+for+Bitbucket
看看https://confluence.atlassian.com/display/BITBUCKET/Write+brokers+%28hooks%29+for+Bitbucket
It looks like the BitBucket folks may not support Ruby, they do support a notification mechanism.
看起来 BitBucket 的人可能不支持 Ruby,他们确实支持通知机制。
UPDATE: https://confluence.atlassian.com/display/BITBUCKET/Manage+Webhooks#ManageWebhooks-create_webhook
更新:https: //confluence.atlassian.com/display/BITBUCKET/Manage+Webhooks#ManageWebhooks-create_webhook