2012-05-04 157 views
5

[Update2] 因此,当我从CLI运行git时,它会提示我输入密码吗?我能够使用ssh私钥的密码访问github服务器,但我从来没有在Jenkins中提示这一点,也没有要求提供它。 [/ Update2]EC2/AWS,Jenkins,Git,SSH

[更新] 是的。我在EC2上的一个Ubuntu实例上运行这个。我在/var/lib/jenkins/.ssh中生成了由Jenkins创建的用户的ssh密钥。我在Jenkins中设置了安全选项来使用Unix用户/组。我想让詹金斯从git(github)中拉出来。我得到以下错误:

hudson.plugins.git.GitException: Could not clone [my personal repo] 
    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:832) 
    at hudson.FilePath.act(FilePath.java:814) 
    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:581) 
    at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:470) 
    at hudson.model.Run.run(Run.java:1434) 
    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]:bobbylo/Verbify.git /var/lib/jenkins/.jenkins/jobs/build_dev/workspace" returned status code 128: 
stdout: Initialized empty Git repository in /var/lib/jenkins/.jenkins/jobs/build_dev/workspace/.git/ 

stderr: Permission denied (publickey). 
fatal: The remote end hung up unexpectedly 

我已经通过Github的ssh教程。我在EC2实例上生成了一个私钥。将它放到用户的.ssh目录中,jenkins。将公钥放在Github上(同时尝试部署密钥+普通SSH密钥)。我已经验证了我可以做git over-the-wire操作(拉,克隆等),并且它可以从CLI和用户一起工作。我已经为用户正确设置了unix用户/组权限(事实上,当我更改它时,我在Jenkin的控制台日志中看到了错误日志更改)。当我尝试使用Jenkin git插件或执行Jenkins shell命令时,出现上述错误。

我读过关于ssh-agent和ssh-add以及如何将它与您的shell启动脚本绑定,因此您不需要为每个命令输入密码 - 我不确定这是否与此处相关。

否则我不知道还有什么我可以尝试。任何提示将有所帮助!

+0

而http://stackoverflow.com/questions/6515039/jenkins-git-permission-denied-publickey没有帮助吗? – VonC

+0

我认为你使用Linux?如果是这样的话,Jenkins可能会以用户“jenkins”的身份运行。用户“jenkins”是否可以访问必要的SSH密钥(可能位于/var/lib/jenkins/.ssh)? – msandiford

+0

我在AWS上的ubuntu盒子上。是的,我正在使用的用户是/ var/lib/jenkins中的jenkins – tom

回答

4

想通了:

- 它证明,如果你运行它不会因为它使用shell环境中,一个守护你跑了它。 - 它也发现任何需要用户提示的cmd(如ssh复述),Jenkins将其视为错误。

的解决方案,现在是:

-Run詹金斯后我加入了通过GitHub的酒吧关键的ssh-agent SSH-添加,使其不提示复述。

如果我想运行Jenkins作为守护进程,我想在运行之前必须正确设置ssh-agent(我不认为它使用当前的shell环境?)。

0

正面临类似的问题,我所要做的就是确保部署密钥是在作为jenkins安装的一部分创建的用户“jenkins”嵌入后生成的,然后在您拥有jenkins服务器后重新启动jenkins服务器复制github中的部署密钥中的公钥。