Gradle SSH Plugin provides SSH facilities such as command execution or file transfer on Gradle.
Read the document for details, and get the template project for quick start.
Add the plugin into your build script. Check the latest version in releases.
plugins {
id 'org.hidetake.ssh' version 'x.y.z'
}Define remote hosts and describe SSH operations in the task.
remotes {
webServer {
host = '192.168.1.101'
user = 'jenkins'
identity = file('id_ecdsa')
}
}
task deploy << {
ssh.run {
session(remotes.webServer) {
put 'example.war', '/webapps'
execute 'sudo service tomcat restart'
}
}
}This is an open source software licensed under the Apache License Version 2.0. Feel free to open issues or pull requests.
Gradle SSH Plugin internally uses Groovy SSH library. It depends on JSch.
The document is maintained on the repository of Groovy SSH.
We can run acceptance tests to verify behavior of the plugin on Gradle environment.
Prerequisite:
- SSH service should be available on the remote host given by env var
EXT_SSH_HOST - SSH service should allow the user given by env var
EXT_SSH_USERto login with the private key placed at~/.ssh/id_extwithout passphrase - SSH service should accept SFTP subsystem
Run test task.
./gradlew :acceptance-tests:testBuild with JDK 7 for compatibility. Do not build with JDK 8.
Push a versioned tag to GitHub and Travis CI will upload the artifact to Bintray.