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

ilmyapht  于 4个月前  发布在  Kotlin
关注(0)|答案(1)|浏览(58)

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

tasks.create("deploy") {

        val myServer = Remote(
                mapOf<String, String>(
                        "host" to "192.168.1.1",
                        "user" to "username",
                        "password" to "password"))

        doLast {

            ssh.run(delegateClosureOf<RunHandler> {
                settings(
                        delegateClosureOf<PerServiceSettings>{
                            mapOf(
                                    "knownHosts" to AllowAnyHosts.instance,

                                    )
                        }
                )
                session(
                        myServer,
                        delegateClosureOf<SessionHandler> {
                    put(
                            hashMapOf(
                                    "from" to "${project.rootDir}/deploy",
                                    "into" to "/home/username/"))
                })
            })
        }

    }

字符串

tasks.create("deploy") {

        val myServer = Remote(
                mapOf<String, String>(
                        "host" to "192.168.1.1",
                        "user" to "username",
                        "password" to "password"))
        ssh.settings (
                    delegateClosureOf<GlobalSettings>{
                        mapOf(
                                "knownHosts" to AllowAnyHosts.instance,

                        )
                    }
            )

        doLast {

            ssh.run(delegateClosureOf<RunHandler> {

                session(
                        myServer,
                        delegateClosureOf<SessionHandler> {
                    put(
                            hashMapOf(
                                    "from" to "${project.rootDir}/deploy",
                                    "into" to "/home/username/"))
                })
            })
        }

    }

von4xj4u

von4xj4u1#

val myServer = Remote(
                mapOf<String, String>(
                        "host" to "192.168.1.1",
                        "user" to "username",
                        "password" to "password"
                        "knownHosts" to AllowAnyHosts.instance                       ))

字符串
将配置移至远程,

相关问题