Vicky
Vicky

Reputation: 51

Unable to clone Git project in Jenkins

I am under a proxy network and i have tried cloning a public git repo to jenkins. But i am facing Failed to connect to repository : Error performing command: C:\Program Files\Git\bin ls-remote -h git@hostname:username/project.git HEAD.

I have even set up the path of git installations as : C:\Program Files\Git\bin and name as Default in git installations under Jenkins configure settings.

Any help would be appreciated. Thanks in Advance

Upvotes: 1

Views: 2438

Answers (4)

Coral Monisha P S
Coral Monisha P S

Reputation: 21

Please find your git.exe file in your local( for me it's C:\Program Files\Git\bin\git.exe) and set this under Git Path of Jenkin's Global Tool Configuration. This would solve this issue

Upvotes: 2

Vicky
Vicky

Reputation: 51

Thank you for your responses. Following are the things which I have done to resolve the above issue: 1) I have unset the proxy settings in my local. 2) Saved the Username and password of my user in Jenkins, (In Windows, Under list of services -> Jenkins -> Properties -> Login), so that the repo will clone using my user in Jenkins. (By Default, Jenkins won't run with our user). and hence, since I have access to the git repo, and I have mentioned Jenkins to use my own username while cloning, the authentication got successful and I could able to clone the git repo in the Jenkins. :) –

Upvotes: 0

DTeuchert
DTeuchert

Reputation: 523

Please check your SSH configuration in GitLab / GitHub, do you store the public key correctly. Just to insure the problem occures somewhere else, try to use the http url instead of the ssh: git ls-remote -h http://<username>:<password>@<hostname>/<namespace>/<project.git>

Note that the part behind the colon (git@hostname:username/project.git) is not necessarily your username, its the namespace of the project. Maybe you switched something there.

Upvotes: 0

Calvin Zhou
Calvin Zhou

Reputation: 327

A few things to check: 1. Ensure you can run this git command successfully in the server where Jenkins is running: git.exe ls-remote -h git@hostname:username/project.git. It's to ensure git, network connetion and your account is working 2. Congiure the repo in Jenkins SCM/GIT portion, in fact Jenkins will do validation and check against your configuration and return failure once the repo is indicated

Normally, it's not recommended to use hostname:username here, just use the plain url if it's a public repo, or use SSH key for a private repo (SSK key can be configured in Jenkins Global Credentials section.

Upvotes: 0

Related Questions