我正在尝试配置 Jenkins(在 Windows Server 2008 上运行)以连接到 GitLab 6.0 存储库(在 Linux 机器上)。
在我的本地 Windows 框中,我可以使用 SSH URL 来克隆我的 GitLab 服务器上的项目。我有 some issues使用 HTTP URL,但我确实设法通过使用 Eclipse 插件的身份验证使用 HTTP 进行连接。
在 Jenkins 项目配置屏幕上,我尝试过:
Failed to connect to repository :
Command "d:\tools\Git\bin\git.exe ls-remote -h http://myserver.domain/mygroup/myproject.git HEAD"
returned status code 128:
stdout: stderr: error: The requested URL returned error: 504 while accessing
http://myserver.domain/mygroup/myproject.git/info/refs?service=git-upload-pack
fatal: HTTP request failed
当我在浏览器中尝试此 URL 时,我收到了一个身份验证 pop 窗口。如果我输入我的电子邮件和密码,我可以成功下载分支和标签列表。
...好的,我应该可以在 URL 中指定用户名和密码,对吧?
http://username:password@myserver.domain/mygroup/myproject.git
...不:
http://username:password@myserver.domain/mygroup/myproject.git/info/refs not valid: is this a git repository?
Windows GUI 使用 SSH 没有任何问题。
...虽然 Jenkins 似乎不太喜欢:git@myserver.domain:mygroup/myproject.git
错误“请输入 Git 存储库”仍然存在,当我尝试保存配置时,我看到以下堆栈跟踪:
Exception: java.lang.RuntimeException: Failed to instantiate class hudson.plugins.git.GitSCM from {"value":"2", "userRemoteConfigs": {"url":"git@myserver.domain:mygroup/myproject.git", "name":"origin","refspec":"" }, "branches":{"name":""}, "includedRegions":"","excludedRegions":"","excludedUsers":"", "localBranch":"","relativeTargetDir":"","reference":"", "scmName":"", "gitConfigName":"","gitConfigEmail":"", "pruneBranches":false,"skipTag":false,"clean":false,"remotePoll":false, "disableSubmodules":false,"recursiveSubmodules":false, "authorOrCommitter":false,"wipeOutWorkspace":false,"ignoreNotifyCommit":false, "useShallowClone":false,"":["","0"], "gitTool":"Default", "browser":{"stapler- class":"hudson.plugins.git.browser.FisheyeGitRepositoryBrowser"} Stacktrace: javax.servlet.ServletException: java.lang.RuntimeException: Failed to instantiate class hudson.plugins.git.GitSCM from {...} at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:725) ... Caused by: java.lang.RuntimeException: Failed to instantiate class hudson.plugins.git.GitSCM from {...} at hudson.model.Descriptor.newInstance(Descriptor.java:617) ... Caused by: java.lang.NullPointerException at hudson.scm.RepositoryBrowser.normalizeToEndWithSlash(RepositoryBrowser.java:85) at hudson.plugins.git.browser.FisheyeGitRepositoryBrowser.<init>(FisheyeGitRepositoryBrowser.java:37)
我尝试添加“ssh”协议(protocol):
ssh://git@myserver.domain:mygroup/myproject.git
Jenkins 立即使用react:
stderr: ssh: myserver.domain:mygroup: no address associated with name
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
最佳答案
作为I commented :
也许 Jenkins 不支持 scp 语法 (with ':
') Try
ssh://git@myserver.domain/mygroup/myproject.git
如“.ssh config with amazon ec2 and git”中所述,使用“:
”通常涉及一个~/.ssh/config 文件
,它解析“:”之前的字符串进入服务器、用户、端口和 ssh key 。
Jenkins 可能更好地理解 git@myserver.domain/mygroup/myproject.git
而不是 git@myserver.domain:mygroup/myproject.git
。
关于git - 在 Jenkins 中配置 GitLab 存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18501767/