4

我有一个 gitPoller 设置为每 60 秒运行一次,但宁愿使用 post-commit 钩子。我对如何做到这一点感到困惑。我知道我应该将git_buildbot.py文件复制到某个地方,但不确定确切的位置。
另外,我不知道在 git hooks 下为 post-receive 文件写什么。

4

3 回答 3

1

假设您的基础 Git 存储库(在您的 Git 服务器上)位于/var/git/yourproject,那么您将git_buildbot.py/var/git/yourproject/hooks. 将(正确编辑的)git_buildbot.py文件放入该目录后,您应该chmod 755 git_buildbot.py确保它是可执行的(假设您的 Git 服务器是 Unix/Linux 的某种风格。)

完成并测试后,您可能应该关闭 CI 服务器上的 gitPoller。

于 2013-07-04T22:42:26.737 回答
1

@Tlu:只是为了协议:我遇到了同样的问题,最后我发现自己安装了一个客户端 git hook(在本教程中提到的 /home/myself/project/.git/hooks 中)而不是服务器side git hook(它必须位于 /srv/git/project/hooks 之类的地方)。

所以我只是不小心错过了使用正确的文件夹,因为在我的 buildbot 设置中,两个目录都在同一台机器上,也许昨天酒吧里喝了一杯不好的饮料;)

只是一个愚蠢的错误,但如果有人陷入同样的​​陷阱,我想让你知道。

于 2017-01-17T14:00:35.167 回答
1

您可以为此使用 Buildbot 的Change Hooks

poller钩子添加到文件中的www设置中master.cfg

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 在您提交后立即轮询存储库。上面的脚本也可用作接收后挂钩。

于 2021-03-23T07:27:41.773 回答