3

In order for Jenkins to be able to have access to multiple repositories on the same server, I set the .ssh/config as follow:

Host a.github.com
  HostName github.com
  User git
  IdentityFile ~/.ssh/project-a-id_rsa

# same for other repos

and set the Jenkins jobs' Source Code Management (SCM), to git and git@a.github.com:user/repo_a.git. It works fine.

Problem
I want those jobs to be triggered on push events so I set a webhook service in github, .i.e, Jenkins (GitHub plugin). The request received from the webhook are "POST for https://github.com/user/repo_a" which is a different host than the one set in the SCM, .i.e, a.github.com.
Because they are different, the job does not build automatically.

Ugly Solution
I got something running by setting the SCM to github.com and override the remote url of the project's git config once cloned with a.github.com. So the SCM would match the webhook, and jenkins when running git push would use the .ssh/config info.

Question
What else can I do ? Is there a better, easily automated way to achieve this?

oldergod
  • 15,033
  • 7
  • 62
  • 88
  • I have the same problem. I am getting timeout errors on the github webhooks page and I think it is because I am using private repos (so ssh keys) – bny Jan 14 '16 at 11:43

1 Answers1

0

I stopped using the deploy key and added my own account credentials on jenkins to be able to deal with all repositories without having to change the host with .ssh/config.

oldergod
  • 15,033
  • 7
  • 62
  • 88