我正在使用Jenkins version - 2.332.1jenkins ssh gerrit 存盤庫克隆有問題。詳情如下,
Jenkins Git plugin Version 4.10.3
搭建服務器環境:-
$ ssh -V
OpenSSH_8.2p1 Ubuntu-4ubuntu0.3, OpenSSL 1.1.1f 31 Mar 2020
$ git --version
git version 2.33.1
Jenkins 構建控制臺日志:-
11:35:13 > git config remote.origin.url ssh://[email protected]:29418/ndk/linux/kernal-image # timeout=10
11:35:13 Fetching upstream changes from ssh://[email protected]:29418/ndk/linux/kernal-image
11:35:13 > git --version # timeout=10
11:35:13 > git --version # 'git version 2.33.1'
11:35:13 > git fetch --tags --force --progress -- ssh://[email protected]:29418/ndk/linux/kernal-image refs/heads/*:refs/remotes/origin/* # timeout=10
11:35:13 ERROR: Error fetching remote repo 'origin'
11:35:13 hudson.plugins.git.GitException: Failed to fetch from ssh://[email protected]:29418/ndk/linux/kernal-image
11:35:13 at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:1001)
11:35:13 at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1242)
11:35:13 at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1302)
11:35:13 at hudson.scm.SCM.checkout(SCM.java:540)
11:35:13 at hudson.model.AbstractProject.checkout(AbstractProject.java:1215)
11:35:13 at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:645)
11:35:13 at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:85)
11:35:13 at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:517)
11:35:13 at hudson.model.Run.execute(Run.java:1896)
11:35:13 at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44)
11:35:13 at hudson.model.ResourceController.execute(ResourceController.java:101)
11:35:13 at hudson.model.Executor.run(Executor.java:442)
11:35:13 Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --force --progress -- ssh://[email protected]:29418/ndk/linux/kernal-image refs/heads/*:refs/remotes/origin/*" returned status code 128:
11:35:13 stdout:
11:35:13 stderr: Unable to negotiate with 165.55.66.77 port 29418: no matching key exchange method found. Their offer: diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
11:35:13 fatal: Could not read from remote repository.
11:35:13
11:35:13 Please make sure you have the correct access rights
11:35:13 and the repository exists.
11:35:13
11:35:13 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2671)
11:35:13 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2096)
11:35:13 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:84)
11:35:13 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:618)
11:35:13 at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:999)
11:35:13 ... 11 more
11:35:13 ERROR: Error fetching remote repo 'origin'
11:35:13 Finished: FAILURE
在終端 ssh 連接到 gerrit 作業,結果如下,
$ ssh -p 29418 [email protected]
**** Welcome to Gerrit Code Review ****
Hi ProUser ., you have successfully connected over SSH.
Unfortunately, interactive shells are disabled.
To clone a hosted Git repository, use:
git clone ssh://[email protected]:29418/REPOSITORY_NAME.git
用詹金斯解決問題。請幫助我解決可能的解決方法。
uj5u.com熱心網友回復:
在運行 Jenkins 控制器的服務器上(假設它與您手動測驗 ssh 連接的服務器相同),添加到 .bashrc
export GIT_SSH_COMMAND='ssh -Tv'
這將允許準確查看正在運行的 SSH 命令以及它在何處尋找其 SSH 密鑰對。
為此,您需要仔細檢查 Jenkins 控制器正在使用哪個帳戶運行(root 或您自己用于手動測驗的同一用戶帳戶)
而且問題還在于默認使用的埠不是29418,而是22。
為了確保您使用的是正確的埠(再次假設 Jenkins 使用與您使用的用戶帳戶相同的用戶帳戶運行):
將 Gerrit 服務器 URL 替換為
gerrit:REPOSITORY_NAME.git添加一個 ~/.ssh/config 檔案:
Host gerrit
Hostname 165.55.66.77
User prj-user
Port 29418
IdentityFile ~/.ssh/TheRightPrivateKey
KexAlgorithms diffie-hellman-group1-sha1,diffie-hellman-group1-sha1
這樣,您就可以確定 SSH URL/命令是正確的,使用正確的埠/密鑰/用戶/主機名。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/448481.html
