【发布时间】:2013-07-03 16:22:20
【问题描述】:
我有一个 gitPoller 设置为每 60 秒运行一次,但宁愿使用 post-commit 挂钩。我对如何做到这一点感到困惑。我知道我应该将 git_buildbot.py 文件复制到某处,但不确定确切的位置。
另外,我不知道git hooks下的post-receive文件要写什么。
【问题讨论】:
标签: git continuous-integration buildbot
我有一个 gitPoller 设置为每 60 秒运行一次,但宁愿使用 post-commit 挂钩。我对如何做到这一点感到困惑。我知道我应该将 git_buildbot.py 文件复制到某处,但不确定确切的位置。
另外,我不知道git hooks下的post-receive文件要写什么。
【问题讨论】:
标签: git continuous-integration buildbot
假设您的基本 Git 存储库(在您的 Git 服务器上)位于 /var/git/yourproject,那么您将在 /var/git/yourproject/hooks 中安装 git_buildbot.py 文件。将(正确编辑的)git_buildbot.py 文件放入该目录后,您应该chmod 755 git_buildbot.py 确保它是可执行的(假设您的 Git 服务器是某种 Unix/Linux 风格。)
完成并测试后,您可能应该关闭 CI 服务器上的 gitPoller。
【讨论】:
line = sys.stdin.readline() 或第 278 行冻结。Buildbot 从未收到通知,或者至少在挂钩后没有构建。非常感谢您的帮助
@Tlu:只是为了协议:我遇到了同样的问题,最后我发现自己安装了一个客户端 git hook(在 /home/myself/project/.git/hooks 中,就像in this tutorial 中提到的那样)服务器端 git 钩子(必须位于 /srv/git/project/hooks 之类的地方)。
所以我只是不小心错过了使用正确的文件夹,因为在我的 buildbot 设置中,两个目录都在同一台机器上,而且可能是昨天酒吧里的那杯酒;)
只是一个愚蠢的错误,但如果有人陷入我想让你知道的同一个陷阱。
【讨论】:
您可以为此使用 Buildbot 的 Change Hooks。
将poller 挂钩添加到您的master.cfg 文件中的www 设置:
c['www'] = {
# ...
'change_hook_dialects': {
'poller': True,
},
# ...
}
假设您的 Git 存储库在 Buildbot 中设置如下:
GitPoller(repourl='/path/to/my-project.git',
project='my-project',
pollInterval=3600,
pollAtLaunch=True)
如果您的 Buildbot URL 是 http://localhost:8010/,那么您的提交后挂钩 (.git/hooks/post-commit) 可以是:
#!/bin/bash
curl -s -F poller="$(pwd)" http://localhost:8010/change_hook/poller
(确保脚本可执行:chmod +x post-commit)。
这将通知 Buildbot 在您提交后立即轮询存储库。上面的脚本也可以用作 post-receive 钩子。
【讨论】: