无法连接到存储库:命令“git ls-remote -h

问题描述 投票:4回答:1

我已经在我的jenkins上安装了centos7 server,并尝试构建一个maven构建。创建了一个新的maven构建工作,在SCM我试图从github中提取代码,但它显示了一个错误,如...

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公钥。我不知道如何解决这个问题。任何人都帮助我。谢谢你。

jenkins centos7 github-for-windows
1个回答
0
投票

我也为我的github设置了一个SSH公钥

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

检查您是否有可能缓存凭据的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不应再问你的凭据。

从那里开始,Jenkins的SCM流程,只要詹金斯说你的帐户运行,就应该有效。

© www.soinside.com 2019 - 2024. All rights reserved.