Search code examples
gitmavenjenkinsmaven-release-plugin

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. This is a local git repository.

At this time, jenkins is run as root. SSH keys have been created for root and they have been added appropriately to the git user's 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.

Another strange thing is jenkins can clone the repository successfully before mvn release:prepare is run.

When it tries to push, it gives the Host key verification failed. error.

I have dumbed the build down to be 1 execution step

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

Before responding, please don't suggest the git plugin or maven release plugin. These can't be installed.


Solution

  • Figured it out.

    While localhost was added to roots ~/.ssh/known_hosts file the actual IP of the box was not. Adding the public IP of the box to known_hosts resolved the issue.