Issue
I’m working to integrate Jenkins to a GitHub repo that I have to pull code, and run. I’ve add a GitHub repository URL to a Source Code Management section in a Jenkins job that I have set up. I’ve ssh’ed into the Jenkins server and generated a KeyPair.
I’ve added the generated Public Key to GitHub under the Deploy Keys (I also tried it under SSH key), and my Jenkins job still displays the error “Failed to connect to repository : Command "/opt/{user}/git/bin/git ls-remote -h [email protected]:{project}/{repo}.git HEAD" returned status code 128:
Is there a way to solve this issue? I’ve tried generating a new key pair, and playing around with the credentials used to access the GitHub repo, but I haven’t had any luck.
Any help in the right direction will be greatly appreciated!!
Solution
Make sure to use the JENKINS/SSH Credentials Plugin
That will allow you to indicate, below the ssh URL of your GitHub repo (int he Jenkins job configuration page) which SSH key you are using for your credentials.
Answered By - VonC
Answer Checked By - Willingham (JavaFixing Volunteer)