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

Use*_*ser 5 jenkins github-for-windows centos7

我已经安装jenkinscentos7 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/'
Run Code Online (Sandbox Code Playgroud)

我还为SSH我的github. 我不知道如何解决这个问题。任何人都可以帮助我。提前致谢。

Von*_*onC 1

我还为我的 github 设置了 SSH 公钥

这对 HTTPS URL 的影响为零:SSH 密钥被忽略。

检查您是否有一个 git 凭证助手,它可以缓存您的凭证(GitHub 用户名/密码)

git config credential.helper
Run Code Online (Sandbox Code Playgroud)

例如,它可能是 ' cache'

我建议(如这个答案)将其设置为gnome-keyring

git config --global credential.helper gnome-keyring
Run Code Online (Sandbox Code Playgroud)

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

git ls-remote https://<yourUsername>@github.com/<yourUsername>/<yourRepo.git>
Run Code Online (Sandbox Code Playgroud)

这应该会提示您输入 GitHub 用户名/密码。一旦进入,第二个人git ls-remote不应再次询问您的凭据。

从那里开始,只要 Jenkins 使用您的帐户运行,您的 Jenkins 的 SCM 流程就应该可以工作。