简体   繁体   English

无法在 Jenkins 中克隆 Git 项目

[英]Unable to clone Git project in Jenkins

I am under a proxy network and i have tried cloning a public git repo to jenkins.我在代理网络下,我尝试将公共 git 存储库克隆到 jenkins。 But i am facing Failed to connect to repository : Error performing command: C:\\Program Files\\Git\\bin ls-remote -h git@hostname:username/project.git HEAD.但我面临无法连接到存储库:执行命令时出错:C:\\Program Files\\Git\\bin ls-remote -h git@hostname:username/project.git HEAD。

I have even set up the path of git installations as : C:\\Program Files\\Git\\bin and name as Default in git installations under Jenkins configure settings.我什至将 git 安装的路径设置为:C:\\Program Files\\Git\\bin 并在 Jenkins 配置设置下的 git 安装中将其命名为 Default。

Any help would be appreciated.任何帮助,将不胜感激。 Thanks in Advance提前致谢

Please find your git.exe file in your local( for me it's C:\\Program Files\\Git\\bin\\git.exe) and set this under Git Path of Jenkin's Global Tool Configuration.请在您的本地找到您的 git.exe 文件(对我来说是 C:\\Program Files\\Git\\bin\\git.exe)并将其设置在 Jenkin 的全局工具配置的 Git 路径下。 This would solve this issue这将解决这个问题

A few things to check: 1. Ensure you can run this git command successfully in the server where Jenkins is running: git.exe ls-remote -h git@hostname:username/project.git.需要检查的几件事: 1. 确保您可以在运行 Jenkins 的服务器中成功运行此 git 命令:git.exe ls-remote -h git@hostname:username/project.git。 It's to ensure git, network connetion and your account is working 2. Congiure the repo in Jenkins SCM/GIT portion, in fact Jenkins will do validation and check against your configuration and return failure once the repo is indicated这是为了确保 git、网络连接和您的帐户正常工作 2. 在 Jenkins SCM/GIT 部分配置 repo,实际上 Jenkins 将进行验证并检查您的配置并在指示 repo 后返回失败

Normally, it's not recommended to use hostname:username here, just use the plain url if it's a public repo, or use SSH key for a private repo (SSK key can be configured in Jenkins Global Credentials section.通常,这里不建议使用 hostname:username,如果是公共 repo,则使用普通 url,或者将 SSH 密钥用于私有 repo(SSK 密钥可以在 Jenkins Global Credentials 部分配置。

Please check your SSH configuration in GitLab / GitHub, do you store the public key correctly.请检查您在 GitLab / GitHub 中的 SSH 配置,您是否正确存储了公钥。 Just to insure the problem occures somewhere else, try to use the http url instead of the ssh: git ls-remote -h http://<username>:<password>@<hostname>/<namespace>/<project.git>为了确保问题发生在其他地方,请尝试使用 http url 而不是 ssh: git ls-remote -h http://<username>:<password>@<hostname>/<namespace>/<project.git>

Note that the part behind the colon (git@hostname:username/project.git) is not necessarily your username, its the namespace of the project.请注意,冒号后面的部分 (git@hostname:username/project.git) 不一定是您的用户名,它是项目的命名空间。 Maybe you switched something there.也许你在那里换了东西。

Thank you for your responses.谢谢你的回复。 Following are the things which I have done to resolve the above issue: 1) I have unset the proxy settings in my local.以下是我为解决上述问题所做的事情:1)我在本地取消了代理设置。 2) Saved the Username and password of my user in Jenkins, (In Windows, Under list of services -> Jenkins -> Properties -> Login), so that the repo will clone using my user in Jenkins. 2) 在 Jenkins 中保存我的用户的用户名和密码,(在 Windows 中,在服务列表 -> Jenkins -> 属性 -> 登录),以便 repo 将在 Jenkins 中使用我的用户进行克隆。 (By Default, Jenkins won't run with our user). (默认情况下,Jenkins 不会与我们的用户一起运行)。 and hence, since I have access to the git repo, and I have mentioned Jenkins to use my own username while cloning, the authentication got successful and I could able to clone the git repo in the Jenkins.因此,由于我可以访问 git repo,并且我已经提到 Jenkins 在克隆时使用我自己的用户名,因此身份验证成功,我可以在 Jenkins 中克隆 git repo。 :) – :) –

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM