在jenkins集成给it,执行git命令测试如下:

git ls-remote -h username@mygit.com:username/myproject.git HEAD

报错如下:

Failed to connect to repository : Command "git ls-remote -h username@mygit.com:cc/myproject.git HEAD" returned status code 128:
stdout:
stderr: Host key verification failed.
fatal: The remote end hung up unexpectedly

原因

这需要使用jenkins用户访问mygti.com的主机添加到~/.ssh/known_hosts。

解决

切换为jenkins用户:

sudo su -s /bin/bash jenkins

在jenkins用户下执行刚才的git命令:

git ls-remote -h username@mygit.com:username/myproject.git HEAD

在终端提示如下:

The authenticity of host 'mygit.com (xxx.xxx.xxx.xx)' can't be established.
RSA key fingerprint is 84:8c:14:f2:6f:14:6d:6c:3b:fc:ac:49:a6:7c:7a:41.
Are you sure you want to continue connecting (yes/no)?

输入yes回车。这时,mygit.com就已经添加到~/.ssh/known_hosts。

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐