2012-06-14 32 views
4

我添加了git插件给Jenkins。我已经生成了一个公钥,作为构建服务器上的jenkins用户。我将这个密钥添加为github的部署密钥。我已经添加了jenkins名称和电子邮件的全球git属性,并且电子邮件与公钥的末尾匹配。Jenkins构建使用Git与部署密钥

当詹金斯尝试从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 - [email protected] 
Using strategy: Default 
Cloning the remote Git repository 
Cloning repository origin 
ERROR: Error cloning remote repo 'origin' : Could not clone [email protected]:GenRocket/GenRocket.git 
hudson.plugins.git.GitException: Could not clone [email protected]: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 [email protected]: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 

不知道是什么问题,还是什么我忘了有关于配置做。任何帮助表示赞赏。让我知道你是否需要更多细节。

回答

4

尝试将github添加到jenkins用户的.ssh/known_hosts文件中。如果您手动尝试克隆为jenkins用户,则应提示您将github.com添加为已知主机。一旦你这样做,jenkins应该能够在构建时验证主机密钥。

+1

啊,我试过了。现在我得到以下错误:stderr:Permission denied(publickey)。我会研究这个。谢谢。 – Gregg

+0

如果是公共回购,您可以尝试克隆只读https git地址。那么你将不必处理密钥。 – kjw0188

+1

@Gregg,你有没有想过你的publickey问题?我也有。 – Civilian

6

对于拒绝的权限错误,您需要确保您使用的是您创建的密钥。为此,请在〜/ .ssh目录中创建一个名为“config”的文件。填充配置文件有以下几点:

  • 主机名github.com
  • 用户的git
  • IdentityFile的〜/ .ssh/id_rsa
  • IdentitiesOnly是

只需确保IdentityFile值指向你的钥匙。 :)

验证以下内容:ssh -vT [email protected]