0

I'm trying to configure the git repository in Jenkins, I followed all steps on github documentation but I had the bellow error on my application .

I've configured the agent, then I put the ssh url on jenkins. I've configured the ssh on github as well.

Failed to connect to repository : Command "git ls-remote -h -- git@github.com:user/maven-project.git HEAD" returned status code 128: stdout: stderr: git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists

luiz kava
  • 187
  • 1
  • 2
  • 14

2 Answers2

1

The issue was solved that way

In windows, Jenkins will use the the SSH key of the user it is running as, which is located in the %USERPROFILE%.ssh folder ( on XP, that would be C:\Documents and Settings\USERNAME.ssh, and on 7 it would be C:\Users\USERNAME.ssh). Therefore, you need to force Jenkins to run as the user that has the SSH key configured. To do that, right click on My Computer, and hit "Manage". Click on "Services". Go to Jenkins, right click, and select "Properties". Under the "Log On" tab, choose the user Jenkins will run as, and put in the username and password (it requires one). Then restart the Jenkins service by right clicking on Jenkins (in the services window), and hit "Restart". Jenkins does not support passphrases for SSH keys. Therefore, if you set one while running the initial Github configuration, rerun it and don't set one.

luiz kava
  • 187
  • 1
  • 2
  • 14
  • Good for you. Windows nuances! You should mark your response as answered. That let's other reference it better. – Ian W Nov 12 '19 at 03:14
0

I'm going to say you don't have the credentials configured properly as you did not mention that.

A similar Stack Overflow response is here, for a slightly different worded error. Similar issue here.

The Jenkins site and others have good examples on setting up Jenkins with GitHub.

Ian W
  • 4,559
  • 2
  • 18
  • 37
  • I've configured credential correctly, since I can clone project in terminal CMD .... It justs don't work in jenkins.... to solve as worarround I configured as https connection... – luiz kava Nov 12 '19 at 02:16