使用gradle进行springboot项目部署:任务':deploytest'的执行失败

时间:2016-01-08 12:23:06

标签: java spring gradle

我用gradle编写一个springboot项目,我想部署它。

以下是build.gradle中代码的一部分:

remotes {
  localtest {
    host = '192.168.0.116'
    user = 'root'
    password = '*****'
  }
}

task deploytest(dependsOn: build) << {
  ssh.run {
    session(remotes.localtest) {
      put from: 'build/libs/test-0.0.1-SNAPSHOT.jar', into: '/opt/test/'
      execute "cd /opt/tieba"
      execute 'nohup java -jar -Dspring.profiles.active=test test-0.0.1-SNAPSHOT.jar & echo $! > application.pid'
    }
  }
}

然后我运行gradle deploytest,但它遇到了问题:

FAILURE: Build failed with an exception.

* Where:
Build file 'E:\github\spring-projects\test\build.gradle' line: 97

* What went wrong:
Execution failed for task ':deploytest'.
> reject HostKey: 192.168.0.116

详细

org.gradle.api.tasks.TaskExecutionException:任务':deploytest'的执行失败。

引起:com.jcraft.jsch.JSchException:拒绝HostKey:192.168.0.116

gradle error details 01  gradle error details 02

2 个答案:

答案 0 :(得分:1)

遇到同样的问题,服务器正在使用ED25519。

我删除了~/.ssh/known_hosts中的相应行,使用ssh-keyscan -t rsa myserver.tld检索了rsa横幅并将结果复制回known_host

看起来比设置knownHosts = allowAnyHosts

更好

答案 1 :(得分:0)

我通过在ssh配置中设置knownHosts = allowAnyHosts来修复它,完成设置是

remotes {
   localtest {
     host = '192.168.0.116' 
     user = 'root' 
     knownHosts = allowAnyHosts 
     password = '*****' 
   }
}