我将git插件添加到Jenkins。我在构建服务器上生成了一个公共密钥作为jenkins用户。我将此密钥添加为github的Deploy Key。我已经使用jenkins名称和电子邮件添加了全局git属性,并且电子邮件与公钥末尾的内容匹配。
当Jenkins试图从git存储库(在Github上托管)中取出时,我得到以下内容:
Started by user anonymous
Building in workspace /var/lib/jenkins/jobs/Test Deployment/workspace
Checkout:workspace / /var/lib/jenkins/jobs/Test Deployment/workspace - hudson.remoting.LocalChannel@9ba3afe
Using strategy: Default
Cloning the remote Git repository
Cloning repository origin
ERROR: Error cloning remote repo 'origin' : Could not clone git@github.com:GenRocket/GenRocket.git
hudson.plugins.git.GitException: Could not clone git@github.com:GenRocket/GenRocket.git
at hudson.plugins.git.GitAPI.clone(GitAPI.java:245)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1121)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1063)
at hudson.FilePath.act(FilePath.java:839)
at hudson.FilePath.act(FilePath.java:821)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1063)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1218)
at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:586)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:475)
at hudson.model.Run.run(Run.java:1438)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:239)
Caused by: hudson.plugins.git.GitException: Command "git clone --progress -o origin git@github.com:GenRocket/GenRocket.git /var/lib/jenkins/jobs/Test Deployment/workspace" returned status code 128:
stdout: Cloning into /var/lib/jenkins/jobs/Test Deployment/workspace...
stderr: Host key verification failed.
fatal: The remote end hung up unexpectedly
不确定问题是什么或关于配置我忘记了什么。任何帮助表示赞赏。如果您需要更多详细信息,请与我们联系。
答案 0 :(得分:6)
对于权限被拒绝错误,您需要确保使用已创建的密钥。为此,在〜/ .ssh目录中创建一个名为“config”的文件。使用以下内容填充配置文件:
确保IdentityFile值指向您的密钥。 :)
使用以下内容进行验证:ssh -vT git@github.com
答案 1 :(得分:4)
尝试将github添加到jenkins用户的.ssh / known_hosts文件中。如果您手动尝试克隆为jenkins用户,则应提示您将github.com添加为已知主机。一旦你这样做,jenkins应该能够在构建时验证主机密钥。