如何配置Buildbot以轮询私有git仓库?

4
如何配置Buildbot以轮询私有Git存储库? GitPoller文档没有提到私有存储库。我的master/gitpoller-workdir文件夹结构看起来很像典型的.git仓库文件夹,因此我假设如果我修改config文件以包括以下内容:
[remote "origin"]
    url = git@myprivatehost.com:myuser/myprivateproject.git
    fetch = +refs/heads/*:refs/remotes/origin/* 

假设我的私有SSH密钥已经加载到某个地方,那么它应该可以正常工作。

3个回答

2

所有配置都应该在master.cfg文件中完成。我认为修改master/gitpoller-workdir不是一个好主意。你可以在URL中插入用户名和密码来访问git仓库:

git clone http://USERNAME:PASSWORD@example.com:foobaz/myrepo.git

以这种方式访问将直接访问您的私有仓库。在 master.cfg 文件中,它将是这样的:
c['change_source'].append(changes.GitPoller
    ("http://USERNAME:PASSWORD@example.com:foobaz/myrepo.git",
    workdir='gitpoller-workdir', 
    branch='master',
    pollinterval=120)

2
我的远程仓库只允许使用SSH密钥,不支持密码。Buildbot支持这个吗? - Cerin
1
Buildbot 1.3.0 将支持此功能。 - p12

2

1

BuildBot似乎正在使用底层的git操作系统命令来执行GitPoller,这本身只会调用ssh

gitbin
    path to the Git binary, defaults to just 'git'

所以我认为您可以使用标准的~/.ssh/config声明来提供私有存储库的密钥。创建一个声明,类似于工作程序(和构建主机)主目录中使用您特定密钥的声明;

# cat /home/worker/.ssh/config

Host github.com
  ClearAllForwardings yes
  User git
  IdentityFile /home/worker/.ssh/id_rsa.github-somekey-specific-to-github

然后,buildbot将使用该密钥。
我认为,如果您想使用每个仓库的密钥,则可以这样做;
Host repo_1_github.com
  Hostname github.com
  ClearAllForwardings yes
  User git
  IdentityFile /home/worker/.ssh/id_rsa.github-somekey-specific-to-github

Host repo_2_github.com
  Hostname github.com
  ClearAllForwardings yes
  User git
  IdentityFile /home/worker/.ssh/id_rsa.github-some-other-key

然后在Buildbot中相应地调整您的URL。

git@repo_1_github.com:organization/my_repo_thing_1.git
git@repo_2_github.com:organization/my_repo_thing_2.git

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接