透過
Hudson自動建構
Maven專案時,如果想要透過SFTP將檔案上傳到應用伺服器去,可以透過
Maven Wagon Upload plugin來自動上傳,如果是手動下命令(mvn clean package wagon:upload)時可以自己打yes,但是如果透過Hudson自動執行時,無法Build結束,導致Hudson的log檔被撐爆,裡面不斷被寫入類似下面的訊息:
The authenticity of host '10.66.19.16' can't be established.
RSA key fingerprint is 1e:8e:82:dd:18:92:50:50:d0:3c:51:ff:39:1c:ef:6c.
Are you sure you want to continue connecting? (yes/no):
解決方法就是自己手動建立.ssh目錄及know_hosts檔案,並將對方伺服器的key值填入即可:
mkdir /var/lib/hudson/.ssh
cat /root/.ssh/known_hosts |grep 10.66.19.16 >> /var/lib/hudson/.ssh/known_hosts
chown -R hudson:hudson /var/lib/hudson/.ssh
參考資料
http://mojo.codehaus.org/wagon-maven-plugin/upload-mojo.html