简体   繁体   English

Maven 发布 git-push “主机密钥验证失败。”

[英]Maven release git-push "Host key verification failed."

When I am trying to have jenkins run a mvn -B release:prepare it gets to the point where it is to push changes to git, but fails with Host key verification failed.当我尝试让jenkins运行mvn -B release:prepare它到达了push更改push送到 git 的地步,但由于Host key verification failed. This is a local git repository.这是一个本地 git 存储库。

At this time, jenkins is run as root .此时, jenkinsroot身份运行。 SSH keys have been created for root and they have been added appropriately to the git user's authorized_keys .已为root创建了 SSH 密钥,并将它们适当地添加到 git 用户的authorized_keys

In fact, I can ssh to the build machine, su to root run git clone git@localhost:my-project.git clone successfully, create a branch and push that branch to origin successfully.事实上,我可以ssh到构建机器, suroot运行git clone git@localhost:my-project.git clone成功,创建一个分支并将该分支成功推送到origin

Another strange thing is jenkins can clone the repository successfully before mvn release:prepare is run.另一个奇怪的事情是jenkins可以在mvn release:prepare运行之前成功克隆存储库。

When it tries to push , it gives the Host key verification failed.当它尝试push ,它给出Host key verification failed. error.错误。

I have dumbed the build down to be 1 execution step我已将构建简化为 1 个执行步骤

git clone git@localhost:my-project.git
mvn -B release:prepare

Before responding, please don't suggest the git plugin or maven release plugin .回复前请不要推荐git插件或maven发布插件 These can't be installed.这些不能安装。

Figured it out.弄清楚了。

While localhost was added to roots ~/.ssh/known_hosts file the actual IP of the box was not.虽然localhost被添加到 root ~/.ssh/known_hosts 文件中,但盒子的实际 IP 不是。 Adding the public IP of the box to known_hosts resolved the issue.将盒子的公共 IP 添加到 known_hosts 解决了这个问题。

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

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