Jenkins GitLab 社区版集成错误

Jenkins GitLab Community Edition Integration Error

我正在尝试为我们的 gitlab.doman.com(GitLab 社区版本 13.0.3)上的项目集成 Jenkins(版本 2.337),它已部署并 运行在 Linux CentosAWS EC2。 当我尝试使用我的 GitLab Access Token 进行测试时,它给我错误提示 Connection Timed Out。 当我尝试使用 Gitlab webhooks 和 SSH 密钥作为凭据而不是访问令牌时,webhooks 成功执行,但 jenkins 上的作业失败并出现以下错误。

我对 Jenkins 很陌生,CI/CD。因此,非常感谢任何指导或帮助解决此问题!

Jenkins 控制台日志:

Started by GitLab push by j****
Running as SYSTEM
Building in workspace /var/lib/jenkins/workspace/xx_xxxxx
The recommended git tool is: NONE
using credential 7c284997-927a-40d9-b1cf-02axxxxxxxxx
 > /usr/bin/git rev-parse --resolve-git-dir /var/lib/jenkins/workspace/xx_xxxxx/.git # timeout=10
Fetching changes from the remote Git repository
 > /usr/bin/git config remote.origin.url git@gitlab.sampledomain.co.kr:xx_xxxxxDetection/xx_xxxxx_detection.git # timeout=10
Fetching upstream changes from git@gitlab.sampledomain.co.kr:xx_xxxxxDetection/xx_xxxxx_detection.git
 > /usr/bin/git --version # timeout=10
 > git --version # 'git version 1.8.3.1'
using GIT_SSH to set credentials GitLab_SSH_Key
 > /usr/bin/git fetch --tags --progress git@gitlab.sampledomain.co.kr:xx_xxxxxDetection/xx_xxxxx_detection.git +refs/heads/*:refs/remotes/origin/* # timeout=10

ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from git@gitlab.sampledomain.co.kr:xx_xxxxxDetection/xx_xxxxx_detection.git
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:1001)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1242)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1302)
    at hudson.scm.SCM.checkout(SCM.java:540)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1215)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:645)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:85)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:517)
    at hudson.model.Run.execute(Run.java:1896)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44)
    at hudson.model.ResourceController.execute(ResourceController.java:101)
    at hudson.model.Executor.run(Executor.java:442)
Caused by: hudson.plugins.git.GitException: Command "/usr/bin/git fetch --tags --progress git@gitlab.sampledomain.co.kr:xx_xxxxxDetection/xx_xxxxx_detection.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: ssh: connect to host gitlab.sampledomain.co.kr port 22: Connection timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2671)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2096)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access0(CliGitAPIImpl.java:84)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.execute(CliGitAPIImpl.java:618)
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:999)
    ... 11 more
ERROR: Error fetching remote repo 'origin'
Finished: FAILURE

A GitLab Access Token 仅适用于 HTTPS URL(替换您的 GitLab 帐户密码)

如果您看到 Connection timed out both 用于 HTTPS URL 和 SSH URL(git@gitlab.sampledomain.co.kr:... 如您的问题),这意味着 gitlab.sampledomain.co.kr 无法从尝试联系您的 Git 存储库托管服务器的 Jenkins 控制器服务器访问。

您需要确保这样的服务器可以执行简单的 curl -v telnet://gitlab.sampledomain.co.kr:22curl -v telnet://gitlab.sampledomain.co.kr:443,然后才能 运行 像 Jenkins 这样的服务。