Jenkins pulls a private GitHub repo using https

I am trying to set up Jenkins (works on Windows) to download a private repository from github.com using the github plugin. It works great for our public repos, but for the private one, no matter what I do, it freezes and then plays like this:

Fetching changes from the remote Git repository
git.exe config remote.origin.url https://github.com/ 
myorganization/MyProjectName.git # timeout=10
Fetching upstream changes from 
https://github.com/myorganization/MyProjectName.git
git.exe --version # timeout=10
git.exe fetch --tags --progress 
https://github.com/myorganization/MyProjectName.git +refs/heads/*:refs/remotes/origin/*
ERROR: Timeout after 10 minutes
ERROR: Error fetching remote repo 'origin'

      

Questions:

  • Perhaps Jenkins pulled the repo using https and credentials instead of ssh. If so, what's the trick? Obviously this is theoretically possible, since I never had deployment keys in my account or git repos, but Visual Studio can interact with the repo using my credentials and https .... but VS and GitHub for Windows are registered as " Authorized Apps "on GitHub. https://www.blazemeter.com/blog/how-start-working-github-plugin-jenkins sounds exactly what I'm looking for and I did create a token on the git site, set github.com as my git server to Jenkins, tested it using generated GitHub token (on Jenkins server config page) and it works, but when I do the build it won't pull the repo.

  • If you can't do it the same way in Jenkins, why would they have a field in the build config to assign git credentials? Are these credentials not used for ssh?

  • If possible, why does all the documentation seem to point to the use of deployment keys and ssh? What is the advantage? It looks like the "known_hosts" key and file pairs generate hassle and not just username / password input.

  • Any idea why it does it from time to time and just doesn't work right away?

Background: I've read a lot about this and it looks like everyone is doing it differently, for example: Jenkins CI Authentication for Private Github Repository Most people seem to be going through this process of generating key pairs and using ssh. I went down this route and the combination of corporate security and lack of documentation made it quite painful (I think I'm close, but a firewall is blocking me, so I'm looking through other options before I beg my case for the network guys).

Follow-up: I ended up with ssh path and it works, but I would still be interested to know if http + credentials is possible and why there is space for credentials in the github plugin ...

+3


source to share





All Articles