Jenkins 无法从 Gitlab 克隆,因为超时

Jenkins fail to clone from Gitlab because timeout

我尝试在 Jenkins 中构建我的 Gitlab 项目时遇到错误。

我试过的

  1. 设置系统环境为设置你的环境变量 Git 插件 Jenkins
  2. 在“git”下将“Git可执行文件的路径”更改为 GIT_FOLDER\cmd\git.cmd(不是 GIT_FOLDER\bin\git.exe)
  3. 使用PsExec.exe让“本地系统账户”被访问 Jenkins 服务器有 SSH 密钥或 known_hosts 设置并通过

    验证

    "GIT_FOLDER\bin\ssh.exe" -T git@your.git.server

  4. 甚至成功通过

    中的相同命令获取

    "C:\Program Files (x86)\Git\bin\sh.exe" -login -i window

  5. 填写Gitlab host url and API Token for Jenkins account in Git实验室服务器

  6. 使用没有密码的 ssh 密钥创建凭据并在 项目凭证

Jenkins 构建错误日志

(git_repository.git 代表我的 git 存储库 url)

由用户 Jenkins 发起

在工作区 C:\Program Files (x86) 中构建\Jenkins\jobs\MyApp-Test\workspace

C:\Program Files (x86)\Git\bin\git.exe rev-parse --is-inside-work-tree # timeout=10

正在从远程 Git 存储库获取更改

C:\Program Files (x86)\Git\bin\git.exe config remote.origin.url git_repository.git # timeout=10

正在从 git_repository.git

获取上游更改

C:\Program Files (x86)\Git\bin\git.exe --version # timeout=10

使用 GIT_SSH 设置凭据

C:\Program Files (x86)\Git\bin\git.exe -c core.askpass=true fetch --tags --progress git_repository.git +refs/heads/:refs/remotes/origin/

ERROR: Timeout after 10 minutes
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from git_repository.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:735)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:983)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1016)
at hudson.scm.SCM.checkout(SCM.java:485)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1282)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:610)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:532)
at hudson.model.Run.execute(Run.java:1741)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:381)
Caused by: hudson.plugins.git.GitException: Command "C:\Program Files (x86)\Git\bin\git.exe -c core.askpass=true fetch --tags --progress git_repository.git +refs/heads/*:refs/remotes/origin/*" returned status code -1:
stdout: 
stderr: 
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1591)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1379)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access0(CliGitAPIImpl.java:86)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.execute(CliGitAPIImpl.java:324)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:733)
... 11 more
ERROR: Error fetching remote repo 'origin'

将自由风格项目的凭据更改为默认选项- none -

因为ssh会使用Gitlab插件值的APItoken来访问Gitlab服务器。

因此如果你在项目中指定另一个SSH密钥来访问Gitlab服务器,它们将永远卡住。

我花了一个星期才弄明白。

我在远程应用程序文件夹中错误地创建了一个 .git 文件夹时遇到了同样的错误。删除文件夹修复它。