Kotlin中的gradle-ssh-plugin ssh.settings语法

ilmyapht  于 2024-01-08  发布在  Kotlin
关注(0)|答案(1)|浏览(168)

我正尝试在Kotlin的build.gradle.kts中配置gradle-ssh-plugin。
我发现了这个问题,这对我帮助很大。只要我把我已知的主机条目放在插件knownHosts: new File("${System.properties['user.home']}/.ssh/known_hosts"),的标准位置,一切都很好。
但是我想为这个文件配置一个不同的位置,因为我想把这个文件放在git repo中。
但是不管我在设置中设置了什么,它仍然在使用标准位置,我试过以下方法:

  1. tasks.create("deploy") {
  2. val myServer = Remote(
  3. mapOf<String, String>(
  4. "host" to "192.168.1.1",
  5. "user" to "username",
  6. "password" to "password"))
  7. doLast {
  8. ssh.run(delegateClosureOf<RunHandler> {
  9. settings(
  10. delegateClosureOf<PerServiceSettings>{
  11. mapOf(
  12. "knownHosts" to AllowAnyHosts.instance,
  13. )
  14. }
  15. )
  16. session(
  17. myServer,
  18. delegateClosureOf<SessionHandler> {
  19. put(
  20. hashMapOf(
  21. "from" to "${project.rootDir}/deploy",
  22. "into" to "/home/username/"))
  23. })
  24. })
  25. }
  26. }

字符串

  1. tasks.create("deploy") {
  2. val myServer = Remote(
  3. mapOf<String, String>(
  4. "host" to "192.168.1.1",
  5. "user" to "username",
  6. "password" to "password"))
  7. ssh.settings (
  8. delegateClosureOf<GlobalSettings>{
  9. mapOf(
  10. "knownHosts" to AllowAnyHosts.instance,
  11. )
  12. }
  13. )
  14. doLast {
  15. ssh.run(delegateClosureOf<RunHandler> {
  16. session(
  17. myServer,
  18. delegateClosureOf<SessionHandler> {
  19. put(
  20. hashMapOf(
  21. "from" to "${project.rootDir}/deploy",
  22. "into" to "/home/username/"))
  23. })
  24. })
  25. }
  26. }

von4xj4u

von4xj4u1#

  1. val myServer = Remote(
  2. mapOf<String, String>(
  3. "host" to "192.168.1.1",
  4. "user" to "username",
  5. "password" to "password"
  6. "knownHosts" to AllowAnyHosts.instance ))

字符串
将配置移至远程,

相关问题