简体   繁体   English

无法在詹金斯结帐外部git repo

[英]cant checkout external git repo in jenkins

I have jenkins on openshift. 我有詹金斯在上班。 I can do following and it works. 我可以执行以下操作,并且可以正常工作。

[jenkins-<USER>.rhcloud.com data]\> ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /var/lib/openshift/<NUMBERED DIRECTORY>/app-root/data/.ssh/jenkins_id_rsa git@github.com
Warning: Permanently added 'github.com,207.97.227.239' (RSA) to the list of known hosts.
PTY allocation request failed on channel 0
Hi <USER>! You've successfully authenticated, but GitHub does not provide shell access.
          Connection to github.com closed.

So it does connect to github...even I cloned it worked from shell. 所以它确实连接到github ...即使我从shell克隆它也可以。

But when I try to add repo to a jenkins job it gives following error. 但是,当我尝试将回购添加到詹金斯工作时,会出现以下错误。 Its a private repo. 它是一个私人仓库。

Failed to connect to repository : Command "git ls-remote -h git@github.com:<USER>/test.git HEAD" returned status code 128:
stdout:
stderr: Host key verification failed.
fatal: The remote end hung up unexpectedly

Jenkins is probably running as jenkins and you accepted the host key for <USER> you can confirm this by adding the command whoami to your build steps and confirm the user in jenkins is different from the one in the shell. Jenkins可能以jenkins运行,并且您接受了<USER>的主机密钥,可以通过在构建步骤中添加命令whoami来确认这一点,并确认jenkins的用户与shell中的用户不同。

One solution is to login as jenkins and accept the the key for github. 一种解决方案是以jenkins身份登录并接受github的密钥。

Another is to copy the line from ~/.ssh/known_hosts of github and copy it to the known_hosts in the jenkins folder ~jenkins/.ssh/known_hosts. 另一个方法是从github的〜/ .ssh / known_hosts复制该行,并将其复制到jenkins文件夹〜jenkins / .ssh / known_hosts中的known_hosts。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM