【问题标题】:How to configure Buildbot to poll a private git repo?如何配置 Buildbot 以轮询私有 git 存储库?
【发布时间】:2015-12-08 20:35:39
【问题描述】:

如何配置 Buildbot 以轮询私有 Git 存储库?

GitPoller 文档没有提及私人回购。我的master/gitpoller-workdir 下的文件结构看起来很像典型的.git repo 文件夹,所以我假设我修改config 文件以包含以下内容:

[remote "origin"]
    url = git@myprivatehost.com:myuser/myprivateproject.git
    fetch = +refs/heads/*:refs/remotes/origin/* 

那么假设我的私人 SSH 密钥已加载到某处,它应该可以工作。

【问题讨论】:

    标签: git buildbot


    【解决方案1】:

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

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

    以这种方式访问​​将直接访问您的私有存储库。在 ma​​ster.cfg 文件中,它将如下所示:

    c['change_source'].append(changes.GitPoller
        ("http://USERNAME:PASSWORD@example.com:foobaz/myrepo.git",
        workdir='gitpoller-workdir', 
        branch='master',
        pollinterval=120)
    

    【讨论】:

    • 我的远程仓库只允许 SSH 密钥,不允许密码。 Buildbot 支持吗?
    • Buildbot 1.3.0 将支持这一点。
    【解决方案2】:

    Buildbot 现在支持指定私有 SSH 密钥(这些更改将作为 buildbot 1.3.0 的一部分发布)。见https://github.com/buildbot/buildbot/pull/4178

    免责声明:我是这些 PR 的作者 :-)

    【讨论】:

      【解决方案3】:

      BuildBot 似乎正在为GitPoller 使用底层的git OS 命令,而它本身只会调用ssh

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

      所以我认为您可以使用标准的~/.ssh/config 声明来提供私有仓库的密钥。在与此类似的 worker(和 buildmaster)主目录中创建使用您的特定密钥的声明;

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

      然后构建机器人将使用该密钥。

      我认为如果您想使用每个 repo 密钥,那么可以这样做;

      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
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-11-15
        • 2013-05-17
        • 2019-08-30
        • 2010-12-17
        • 1970-01-01
        • 1970-01-01
        • 2023-03-13
        相关资源
        最近更新 更多