Wednesday, September 14, 2011

Jenkins and Maven SCP Error: reject HostKey

We lost one of our internal build machines recently (that was a sad day), and so we've been rebuilding our Jenkins environment from the ground up. We use scp access for our distributionManagement control in Maven. Because of this, Jenkins broke on our first build with a whole lot of output saying "The host was not known and was not accepted by the configuration", which narrowed down to this exception:

Caused by: com.jcraft.jsch.JSchException: reject HostKey

Our server configurations were properly set in Jenkins' settings.xml, so we thought this would be an easy fix by just ssh-ing to that host which should register it into the hostnames. Not So FAST. We tried this as many different users including ROOT and jenkins. Ran the build again, same error. We tried a lot of things next, most of which I don't care to relive. Nothing worked. Here's what actually worked, on our Ubuntu environment (modify according to your own environment).


This will prompt you to accept the host authenticity, which of course you should accept.

I do not entirely understand why this actually prompts. Since this command shows up as a process running as Jenkins user, which I had already approved the host for. My suspicion is that maven actually runs that command as it's own user. However I don't really know how to verify that suspicion, and now that it works, it's time to move on.

No comments: