简体   繁体   中英

Jenkins integration with Git repository

  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. 在此处输入图像描述

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.

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:\Users\your_windows_user_name here.ssh\known_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:\Users\your_windows_user_name here.ssh\id_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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM