Jenkins Git 插件:无法连接到存储库,返回状态代码 128
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32189765/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Jenkins Git Plugin: Failed to connect to repository, returned status code 128
提问by NicholasKyleHoffman
I'm attempting to clone a remote GitHub enterprise repository and am running into the following error after adding my remote repo's URL to the Git Pluginin my Jenkins configuration:
我正在尝试克隆远程 GitHub 企业存储库,并在将远程存储库的 URL 添加到Jenkins 配置中的Git 插件后遇到以下错误:
hudson.plugins.git.GitException: Command "/usr/bin/git -c askpass=true fetch --tags --progress https://github.com/myUsername/myProject.git refs/heads/*:refs/remotes/origin/*" returned status code 128: stdout: stderr: fatal: unable to access https://github.myOrg.com/myUsername/myProject.git/': Failed to connect to github.com port 443: Operation timed out at...
Configuration details & things I have tried:
配置细节和我尝试过的事情:
- Jenkins URL is at default of http://localhost:8080/(Getting the warning: "Please set a valid host name, instead of localhost")
- All dependencies listed have been installed for the Git Plugin
- I have added git credentials for authorization to my organization's remote repo
- I tried to add my personal (non-enterprise git account) credentials & repo to the plugin with the same result
- I have set my "Path to Git executable" to both 'git' and '/usr/bin/git'
- I can connect to Git both through the command line and in the browser
- Jenkins URL 默认为http://localhost:8080/(收到警告:“请设置有效的主机名,而不是 localhost”)
- 已为Git 插件安装列出的所有依赖项
- 我已将 git 凭据添加到我组织的远程存储库中进行授权
- 我尝试将我的个人(非企业 git 帐户)凭据和 repo 添加到插件中,结果相同
- 我已将“Git 可执行文件的路径”设置为“git”和“/usr/bin/git”
- 我可以通过命令行和浏览器连接到 Git
Questions:
问题:
- Am I somehow supposed to provide authentication (ssh keys) just for Jenkins to use/clone my remote repo?
- Why does Jenkins throw a warning for leaving the default URL? Does this mean I need to 'put' Jenkins somewhere other than my local machine?
- 我是否应该以某种方式为 Jenkins 提供身份验证(ssh 密钥)以使用/克隆我的远程存储库?
- 为什么 Jenkins 会因为保留默认 URL 发出警告?这是否意味着我需要将 Jenkins 放在本地机器以外的其他地方?
I have been troubleshooting this for a few days now and am unsure of what my problem(s) are at this point! Please help!!
我已经对此进行了几天的故障排除,但我不确定此时我的问题是什么!请帮忙!!
采纳答案by Dmitry Savinkov
Regarding your 1st question - you need to associate correct ssh key with appropriate repository. You can do it in
/var/lib/jenkins/.ssh/config
file - detailed explanation is herethis is more robust solution in terms of supporting of multiple git repos OR you can just add correct ssh key into/.ssh
folder. For troubleshooting try to perform clone github repo under jenkins user inside your jenkins box.Regarding your 2nd question. Here are my network settings in jenkins and I have no warning messages:
/etc/hosts
:127.0.0.1 localhost localhost.localdomain
/etc/sysconfig/network
:HOSTNAME=localhost.localdomain
. Your hostname and localhost should be resolved inside jenkins server as well.
关于您的第一个问题 - 您需要将正确的 ssh 密钥与适当的存储库相关联。您可以在
/var/lib/jenkins/.ssh/config
文件中执行此 操作 -此处有详细说明,这是在支持多个 git 存储库方面更强大的解决方案,或者您可以将正确的 ssh 密钥添加到/.ssh
文件夹中。对于故障排除,请尝试在 jenkins 框内的 jenkins 用户下执行 clone github repo。关于你的第二个问题。下面是我的詹金斯网络设置和我没有任何警告信息:
/etc/hosts
:127.0.0.1 localhost localhost.localdomain
/etc/sysconfig/network
:HOSTNAME=localhost.localdomain
。您的主机名和 localhost 也应该在 jenkins 服务器中解析。
回答by NicholasKyleHoffman
Problem has been resolved. Followed steps herefor new keygen. Logged into terminal as: jenkins$ (sudo -i -u jenkins). I was able to eventually add newly generated keys to /Users/Shared/Jenkins/.ssh/id_rsa (I was trying to reproduce how my other ssh keys were stored on my mac in /Users/me/.ssh).
问题已解决。按照此处的步骤获取新的密钥生成器。以以下身份登录终端:jenkins$ (sudo -i -u jenkins)。我最终能够将新生成的密钥添加到 /Users/Shared/Jenkins/.ssh/id_rsa(我试图重现我的其他 ssh 密钥如何存储在我的 mac 上的 /Users/me/.ssh)。
I also had to restrict permission levels on the above SSH key folder to avoid getting an error & authenticating with the ssh -T..and added to git -> account settings -> ssh key (specifically for jenkins).
After that, I went into Jenkins /configure and added my new private key location to CVS. In my project, I had to add credentials (SSH username w/private key) w/"From the Jenkins master ~/.ssh" radio button selected.
我还必须限制上述 SSH 密钥文件夹的权限级别,以避免出现错误并使用 ssh -T.. 进行身份验证并添加到 git -> 帐户设置 -> ssh 密钥(特别是对于 jenkins)。
之后,我进入 Jenkins /configure 并将我的新私钥位置添加到 CVS。在我的项目中,我必须添加凭据(带有私钥的 SSH 用户名),并选择了“来自 Jenkins master ~/.ssh”单选按钮。
回答by gersonZaragocin
It is a bit strange but if you are using gitlab.com, it seems that the error is gone when you login to the website (gitlab.com) using the gitlab account used to clone the project from Jenkins.
这有点奇怪,但是如果您使用的是 gitlab.com,那么当您使用用于从 Jenkins 克隆项目的 gitlab 帐户登录网站 (gitlab.com) 时,错误似乎消失了。