简体   繁体   中英

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.

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.

One solution is to login as jenkins and accept the the key for 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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