4

How do you configure Buildbot to poll a private Git repository?

The GitPoller docs don't make any mention of private repos. The file structure under my master/gitpoller-workdir looks suspiciously like a typical .git repo folder, so I'm assuming if I modify the config file to include something like:

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

then it should work assuming the my private SSH key is loaded somewhere.

Cerin
  • 60,957
  • 96
  • 316
  • 522

3 Answers3

2

All configurations should be inside master.cfg file. I don't think modifying master/gitpoller-workdir would be a good idea. You can access a git repository inserting the username and password in the URL:

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

Acessing in this way will directly access to your private repository. In the master.cfg file it will look like this:

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

Buildbot now supports specifying private SSH keys (these changes will be released as part of buildbot 1.3.0). See https://github.com/buildbot/buildbot/pull/4178.

Disclaimer: I'm the author of these PR :-)

p12
  • 1,161
  • 8
  • 23
1

BuildBot seems to be using the underlying git OS command for GitPoller, which itself is just going to call ssh,

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

so I think you can just use standard ~/.ssh/config declarations to provide the key for the private repo. Create a declaration that uses your specific key in the worker (and the buildmaster) home directories similar to this;

# cat /home/worker/.ssh/config

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

And then the buildbot will use that key.

I think if you want to use a per repo key, then that could be done like so;

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

and then adjust your urls in buildbot appropriately;

git@repo_1_github.com:organization/my_repo_thing_1.git
git@repo_2_github.com:organization/my_repo_thing_2.git
Tom
  • 3,324
  • 1
  • 31
  • 42