How can I check out several private Github repositories using Jenkins

I have a little problem with Jenkins and private Github repositories. To check out a private repo, usually one of two things is required:

  • private SSH user key in this repo
  • registered SSH private key for this repo

The deployment key was executed for this interaction. The problem is that deployment keys must be unique for different projects, so I will have to use different keys every time. This means that I have to add another key to the ssh agent for the Jenkins user for each additional repo.
It also means that, by default, the agent will try to use all available keys and will probably get a connection after several failed attempts with the wrong key.

The Jenkins git plugin does not seem to allow you to point it to an SSH key. Jenkins does not allow command line interaction until validation, so I cannot use bash tricks to set the correct key.

So far, the only solution has been:

  • Create user my_jenkins_account on github
  • Add public key for user
  • Add an account to the repos that I want to verify using Jenkins
  • Add user private key to jenkins user

Any alternative suggestions?

+5
source share
1 answer

This is not quite the answer, just an echo in the dark so you know that I am doing almost the same thing.

  • Run Jenkins as a user named jenkins
  • sudo as this user and create ssh public key
  • Create a free github account called myorg-machines
  • Add this jenkinsssh public key to your account keys myorg-machineson GitHub. I call this key jenkins on server.name.comso that everything is organized.
  • GitHub Machines - Pull only. myorg-machines GitHub .

, klunky, .

+13

All Articles