skip to Main Content
  1. I have installed git 2.7 on my centos server. and created repository at /srv/repo.git. i am able to clone this using the command ssh://user@serverIP:/srv/repo.git.

  2. I have installed jenkins & git on my local machine on Windows 10.

  3. Problem:
    Facing error while setup git repo with jenkins.Please see the screen-shot.
    enter image description here

Error:

Failed to connect to repository : Command "git.exe ls-remote -h -- ssh://username@server_ip:/srv/repo.git HEAD" returned status code 128:
stdout:
stderr: ssh: Could not resolve hostname server_ip: Name or service not known
fatal: Could not read from remote repository.

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

Please help me on this. Thanks in advance.

2

Answers


  1. Chosen as BEST ANSWER

    I find out the solution of this issue..there was an issue of authentication of jenkins with git server. Just resolve using below steps:

    1. Open git bash on local machine and generate public/private keyes using command: ssh-keygen
    2. Copy the id_rsa.pub content to C:Usersyour_windows_user_name here.sshknown_hosts
    3. In jenkins got to Source Code Management->Git->Credentials add
    4. In Jenkins select Kind->SSH Username with private key, Enter directly -> Paste the private generated private key here from the file
    5. on Linux Server go to .ssh/authorized_keys and paste the C:Usersyour_windows_user_name here.sshid_rsa.pub file content here
    6. In jenkins project configuration go to the "Source code management" section and choose git->Repositary url-> paste this ssh://user@serverIP:/srv/repo.git
    7. Select the Credentials which we create in step no. 3 & 4.

  2. You have to exchange ‘server_ip’ with the IP of your server.

    Username should to set to the correct one, too.
    You said that you can clone like this

    ssh://user@serverIP:/srv/repo.git
    

    But Jenkins is trying to clone like this

    ssh://user@server_ip:/srv/repo.git
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search