Jenkins projects Failed to connect to repository - jenkins

Using the steps outlined here I lifted and shifted our Jenkins instance from one windows machine to another windows machine.
Jenkins on the new server launches successfully.
However, the integration with GitHub on all the projects is failing with the following error.
Failed to connect to repository : Command "git.exe ls-remote -h
git#github.com:some_repo_name.git HEAD" returned status code 128:
stdout: stderr: some_user#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.
What have I done wrong?

Related

Why am I unable to configure ssh keys to read a Gerrit repo from Jenkins?

I am in the process of trying to migrate Gerrit and Jenkins to a new datacenter. I have successfully installed the applications on their new hardware, but am having difficulty getting Jenkins to read from a Gerrit repository on the same server.
As the Jenkins user already existed on the server, I updated its ssh keys using one I generated from my account on my laptop (pablo#mena-xps), using the following command:
cat ~/.ssh/id_rsa.pub | ssh -p 29418 pmena#gerrit_host gerrit set-account --add-ssh-key - jenkins
I confirmed that I am able to use this key to interrogate gerrit from my laptop:
pablo#mena-xps=> ssh -p 29418 pmena#gerrit_host gerrit version
gerrit version 2.10
On the Jenkins server, I added the Private key under "Credentials" and then Configured the specific job to use that key to access a specific gerrit repo. That returns the following error in the GUI:
Failed to connect to repository : Command "git -c core.askpass=true ls-remote -h ssh://gerrit_host:29418/my_repo HEAD" returned status code 128:
stdout:
stderr: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
How do I go about troubleshooting this issue? Thank you in advance.
To make a long story short, this issue is resolved. The Jenkins account on Gerrit was removed and recreated, after which I was able to successfully push the ssh key pair.

How to configure Git in Jenkins using windows platform

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
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.
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.

Jenkins on Linux Server Behind VPN Not Connecting to GitHub Webhook

I'm setting up continuous integration of a GitHub repository to automatically be pulled down by Jenkins onto a Linux server that is behind my company VPN that I do not control.
I have setup an Private SSH Key as both Jenkins Credentials and GitHub Deploy Key. I keep getting authenticating errors when Jenkins tries to connect to the SSH Repository URL. Is the VPN causing GitHub to not be able to POST to the server? Or am I missing something else?
ERROR MESSAGE:
Failed to connect to repository : Command "git ls-remote -h git#github.com:MyOrganization/MyRepository.git HEAD" returned status code 128:
stdout:
stderr: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

Jenkins Gitlab Localhost - Failed to connect to repository : Command "git ls-remote -h

I am trying to connect Jenkins with GitLab, both are installed on the same Unix server, in Jenkins Manager System the connection is successful. But in Job when I put the URL in the Repository URL it gives an error message:
"Failed to connect to repository: Command" git ls-remote -h "
We are trying via http: // localhost, but we have already tried to use the domain https://git.MYCLIENT.org.br/REPOSITORY.git, we also have SSH, we use PRIVATE KEY SSH, we use ACCESS TOKEN from GIT, we have done all settings to do. Even so, continue with this mistake!

Configuring Jenkins with Cloud TFS (Supports GIT)

We are trying to configure Cloud TFS (Project Created with Git Support) & Jenkins (Ubuntu Machine).
When ever i try to enter the Repository URL it gives the following error.
Failed to connect to repository : Command "git ls-remote -h
https://xyz.visualstudio.com/DefaultCollection/_git/xyzrepo.git HEAD"
returned status code 128: stdout: stderr: fatal: Authentication
failed
I have generated keys using SSH route, but unfortunately i can't add the key # Cloud TFS Repo.
I have even tried this format https://USERNAME:PASSWORD#example.visualstudio.com/DefaultCollection/_git/Repo_Name but somehow was not successful.
PS: Bare minimum's are installed (GIT & Git plugin for Jenkins)
Any help/instructions is appreciated.
You probably need to enable Alternate Credentials in tfs.
Have a look at this howto

Resources