无法连接到存储库:命令“git的LS-远程-h

问题描述:

我已在centos7 server安装jenkins,并试图建立一个maven构建创建一个新的Maven构建工作,并在SCM我试图从github拉码。但它给我这样的错误......无法连接到存储库:命令“git的LS-远程-h

Failed to connect to repository : Command "git ls-remote -h https://github.com/example.git HEAD" returned status code 128: stdout: stderr: remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/example.git/' 

而且我也设置一个SSH公共密钥我github,我不知道如何解决这个问题。任何帮助me.Thanks提前。

al所以我设置了一个SSH公钥给我的github

这对HTTPS URL没有任何影响:SSH密钥被忽略。

检查,如果你havbe一个git凭证帮手的地方可能缓存凭据(GitHub的用户名/密码)

git config credential.helper 

例如,it could be 'cache'

我会建议(如in this answer)将其设置为gnome-keyring

git config --global credential.helper gnome-keyring 

,然后再次尝试您的git ls-remote,从命令行:

git ls-remote https://<yourUsername>@github.com/<yourUsername>/<yourRepo.git> 

那应该提示您GitHub上的用户名/密码。一旦输入,第二个git ls-remote不应再次要求您的凭据。

从那里,只要詹金斯说你的帐户运行,从你的詹金斯SCM程序应该工作。