我正在同一台服务器上设置 jenkins 和 stash。Stash 通过 http 运行良好。为了让 Jenkins 连接到 Stash,我创建了一个 ssh(使用 Jenkins 用户,并且密钥存储在 /var/lib/jenkins/.ssh/id_rsa.pub 中)。正如指南所说,我将此密钥添加到我的个人资料中并在管理启动>服务器设置中启用了 ssh。
在 jenkins 中,我安装了 Git 插件和 genarl 配置:
全局配置用户名值
全局配置 user.email 值
在项目配置中,我设置了以下字段:
存储库 URL:ssh://git@10.10.2.40:7999/AT/repository1.git
如果我运行该作业,则会收到以下错误:
Building in workspace /var/lib/jenkins/jobs/Test Job/workspace
Checkout:workspace / /var/lib/jenkins/jobs/Test Job/workspace - hudson.remoting.LocalChannel@6bbef70
Using strategy: Default
Cloning the remote Git repository
Cloning repository ssh://git@10.10.2.40:7999/AT/repository1.git
git --version
git version 1.7.12.4
ERROR: Error cloning remote repo 'origin' : Could not clone ssh://git@10.10.2.40:7999/AT/repository1.git
hudson.plugins.git.GitException: Could not clone ssh://git@10.10.2.40:7999/AT/repository1.git
at hudson.plugins.git.GitAPI.clone(GitAPI.java:273)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1044)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:986)
at hudson.FilePath.act(FilePath.java:852)
at hudson.FilePath.act(FilePath.java:825)
at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:986)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1142)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1324)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:676)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:581)
at hudson.model.Run.execute(Run.java:1518)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:236)
Caused by: hudson.plugins.git.GitException: Command "/home/danilo/libexec/git-core/git clone --progress -o origin ssh://git@10.10.2.40:7999/AT/repository1.git /var/lib/jenkins/jobs/Test Job/workspace" returned status code 128:
stdout: Cloning into '/var/lib/jenkins/jobs/Test Job/workspace'...
stderr: Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
at hudson.plugins.git.GitAPI.launchCommandIn(GitAPI.java:897)
at hudson.plugins.git.GitAPI.access$000(GitAPI.java:42)
at hudson.plugins.git.GitAPI$1.invoke(GitAPI.java:269)
at hudson.plugins.git.GitAPI$1.invoke(GitAPI.java:248)
at hudson.FilePath.act(FilePath.java:852)
at hudson.FilePath.act(FilePath.java:825)
at hudson.plugins.git.GitAPI.clone(GitAPI.java:248)
... 14 more
Trying next repository
ERROR: Could not clone repository
FATAL: Could not clone
hudson.plugins.git.GitException: Could not clone
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1056)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:986)
at hudson.FilePath.act(FilePath.java:852)
at hudson.FilePath.act(FilePath.java:825)
at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:986)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1142)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1324)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:676)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:581)
at hudson.model.Run.execute(Run.java:1518)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:236)