git 在 Jenkins 中配置 GitLab 存储库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18501767/
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
Configure GitLab repository in Jenkins
提问by Nicholas Albion
I'm trying to configure Jenkins (running on Windows Server 2008) to connect to a GitLab 6.0 repository (on a linux box).
我正在尝试配置 Jenkins(在 Windows Server 2008 上运行)以连接到 GitLab 6.0 存储库(在 linux 机器上)。
From my local windows box I can use the SSH URLs to clone the projects on my GitLab server. I've had some issuesusing the HTTP URLs, but I did manage to connect using HTTP with authentication using the Eclipse plugin.
从我的本地窗口框中,我可以使用 SSH URL 来克隆我的 GitLab 服务器上的项目。我在使用 HTTP URL 时遇到了一些问题,但我确实设法通过使用 Eclipse 插件的身份验证使用 HTTP 进行连接。
On the Jenkins project config screen I have attempted:
在 Jenkins 项目配置屏幕上,我尝试过:
Failed to connect to repository :
Command "d:\tools\Git\bin\git.exe ls-remote -h http://myserver.domain/mygroup/myproject.gitHEAD"
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
无法连接到存储库:
命令“d:\tools\Git\bin\git.exe ls-remote -h http://myserver.domain/mygroup/myproject.gitHEAD”
返回状态码 128:
标准输出:标准错误:错误:请求的 URL 返回错误:访问时返回错误:504
http://myserver.domain/mygroup/myproject.git/info/refs?service=git-upload-pack
致命:HTTP 请求失败
When I try this URL in a browser I get an authentication popup. If I enter my email & password I can successfully download the list of branches & tags.
当我在浏览器中尝试此 URL 时,我会收到一个身份验证弹出窗口。如果我输入我的电子邮件和密码,我可以成功下载分支和标签列表。
...Okay, so I should be able to specify the username & password in the URL, right?
...好的,所以我应该能够在 URL 中指定用户名和密码,对吗?
...nope:
...不:
http://username:[email protected]/mygroup/myproject.git/info/refsnot valid: is this a git repository?
http://username:[email protected]/mygroup/myproject.git/info/refs无效:这是 git 存储库吗?
The Windows GUIs didn't have any trouble using SSH.
...Jenkins doesn't seem to like that much though:[email protected]:mygroup/myproject.git
The error "Please enter Git repository" still remains, and when I attempt to save the config I see the following stack trace:
Exception: java.lang.RuntimeException: Failed to instantiate class hudson.plugins.git.GitSCM from {"value":"2", "userRemoteConfigs": {"url":"[email protected]: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)
I tried adding the "ssh" protocol:
ssh://[email protected]:mygroup/myproject.git
Windows GUI 使用 SSH 没有任何问题。
...不过詹金斯似乎不太喜欢:[email protected]:mygroup/myproject.git
错误“请输入 Git 存储库”仍然存在,当我尝试保存配置时,我看到以下堆栈跟踪:
Exception: java.lang.RuntimeException: Failed to instantiate class hudson.plugins.git.GitSCM from {"value":"2", "userRemoteConfigs": {"url":"[email protected]: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”协议:
ssh://[email protected]:mygroup/myproject.git
Jenkins immediately reacts:
詹金斯立即做出反应:
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.
stderr: ssh: myserver.domain:mygroup: 没有与名称关联的地址
致命:无法从远程存储库读取。
请确保您拥有正确的访问权限并且存储库存在。
采纳答案by VonC
As I commented:
正如我评论的那样:
Maybe Jenkins doesn't support the scp syntax (with ':
') Try
也许詹金斯不支持 scp 语法(带' :
')试试
ssh://[email protected]/mygroup/myproject.git
As mentioned in ".ssh config with amazon ec2 and git", using ':
' usually involves a ~/.ssh/config file
, which resolves the string preceding the ':' into a server, user, port and ssh key.
正如“使用 amazon ec2 和 git 配置 .ssh 配置”中提到的,使用 ' :
' 通常涉及 a ~/.ssh/config file
,它将 ':' 之前的字符串解析为服务器、用户、端口和 ssh 密钥。
Jenkins might understand better [email protected]/mygroup/myproject.git
instead of [email protected]:mygroup/myproject.git
.
詹金斯可能会更好地理解[email protected]/mygroup/myproject.git
,而不是[email protected]:mygroup/myproject.git
。