git - 在 Jenkins 中配置 GitLab 存储库

标签 git jenkins gitlab

我正在尝试配置 Jenkins(在 Windows Server 2008 上运行)以连接到 GitLab 6.0 存储库(在 Linux 机器上)。

在我的本地 Windows 框中,我可以使用 SSH URL 来克隆我的 GitLab 服务器上的项目。我有 some issues使用 HTTP URL,但我确实设法通过使用 Eclipse 插件的身份验证使用 HTTP 进行连接。

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 窗口。如果我输入我的电子邮件和密码,我可以成功下载分支和标签列表。

...不:

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/

相关文章:

从 Jenkinsfile 设置构建参数时出现 Jenkins 错误

jenkins - Jenkins 管道中作业 DSL 中的工作区路径

ansible - 如何通过gitlab CI检查Ansible?

javascript - NPM 包 - LF 或 CRLF 或自动行结尾?

git - 在 Azure DevOps Git 中强制使用分支命名约定

未完成更改时 Git merge 冲突

svn - git-svn 分支

git - 为什么 Jenkins 的 Git 插件用额外的斜杠重写我的本地 git repo url?

docker - 使用Alpine在Gitlab CI/CD上构建docker镜像

gitlab - Hook 执行成功但返回 HTTP 500 Missing_text_or_fallback_or_attachments