Problem: Red build
Unless your Jenkins project just stopped building with this exception hudson.plugins.git.GitException: Failed to fetch from git@github.com
you are unlikely to get much of this post ;)
I guess there might be bunch of the reasons why you could see this message, but here is what happend to me..
My project hosted on github suddenly started to fail when building in jenkins. Initially I had no clue why and I’ve done bunch of google searches:
1 2 3 |
|
Investigation
Thinking a little bit more about my situation. We have a Jenkins that is connecting to GitHub using different ssh keys depending on project (deploy key approach ). So I continued to google:
1 2 |
|
That led me to additional debugging commands: ssh -vvvT git@github.com
and adding in ~/.ssh/config
1 2 |
|
While checking out projects from github and looking and debugging output problem became quite clear. Git, while using SSH, was authenticating using incorrect ssh key.
Solution
In the end, what happend was that previous day I’ve replaced ~/.ssh/config
on Jenkins box. Among other things, there was a problematic bit of config:
1 2 3 4 |
|
ControlPersist – that automatically starts a background ssh(1) multiplex master when connecting. This connection can stay alive indefinitely, or can be set to automatically close after a user-specified duration of inactivity
Above configuration was causing issues, when different projects were being build on Jenkins that were meant to use different ssh keys (while talking to github).
Removing above config solved the problem.