0

I am trying to connect jenkins to a git repository, to trigger a build whenever any changes are committed to the repository.

Jenkins version - 2.46.3, Java version - 1.7.51, CentOS version - 6.6

My git repository is in a LAN (eg. IP - 10.0.0.1), to clone the repo, I use the below command:

git clone test@10.0.0.1:/path/to/repo

Then, the password for test will be prompted - this properly clones the git repository.

But, when I try to connect with same credentials, IP and path with jenkins, it gives me the error as shown in the below screenshot.

There is a jenkins user in my centOS - I added the SSH key to the ~/.ssh/known_hosts file with that user. But I'm still getting this error.

enter image description here

Can anyone please help on the following?

  1. What is this "Source Code Management" section is meant for?
  2. What does git tries to achieve with git ls-remote -h commmand?
  3. How is the repository URL and credentials fields linked?
  4. Why am I getting the error shown in the screenshot?
Bala Krishnan
  • 374
  • 3
  • 18

1 Answers1

0
  1. "Source Code Management" section is there for situations when you need to checkout aka clone the repository to workspace of Jenkins and ocreastracte on it.
  2. git tries to check accessibility of your repository
  3. about url and credentials, I would strongly suggest to use ssh based url for cloning and ofc the ssh key pairs instead of credentials. In that case url will looks like someghing like this: git clone git@{ip or web address}:{username}/{repository name}.git
BigGinDaHouse
  • 1,282
  • 9
  • 19
  • I cant say presisly cause I do not see the url of git, just mention maybe which way you try to use it ? – BigGinDaHouse May 02 '18 at 07:46
  • As mentioned in the question for clone command, I use similar structure in this command also. `username@{ip-address}:/path/to/repo` – Bala Krishnan May 02 '18 at 08:14
  • try to execute the same commad as in your error message manually and see what is error. Second option, try to use the url in the format I mentioned – BigGinDaHouse May 02 '18 at 08:23
  • I did and this is what I have observed - [https://stackoverflow.com/questions/50131377/git-command-repository-heads-not-listed-while-using-h-switch-with-head-opti] – Bala Krishnan May 02 '18 at 09:35