[英]Jenkins fail to clone from Gitlab because timeout
當我嘗試在 Jenkins 中構建我的 Gitlab 項目時遇到錯誤。
使用 PsExec.exe 讓 Jenkins 服務器訪問的“本地系統帳戶”設置 SSH 密鑰或 known_hosts 並通過以下方式驗證
"GIT_FOLDER\\bin\\ssh.exe" -T git@your.git.server
即使通過相同的命令獲取成功
"C:\\Program Files (x86)\\Git\\bin\\sh.exe" -login -i 窗口
在Gitlab服務器中填寫Jenkins賬號的Gitlab主機url和API Token
(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.access$300(CliGitAPIImpl.java:86)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:324)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:733)
... 11 more
ERROR: Error fetching remote repo 'origin'
將自由風格項目的憑據更改為默認選項- 無 -
因為ssh會使用Gitlab插件值的API token來訪問Gitlab服務器。
因此,如果您在項目中指定另一個 SSH 密鑰來訪問 Gitlab 服務器,它們將永遠卡住。
這花了我一周的時間才發現這一點。
當我錯誤地在遠程應用程序文件夾中創建了一個 .git 文件夾時,我遇到了同樣的錯誤。 刪除文件夾修復了它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.