Created
January 16, 2015 08:54
-
-
Save rundis/d2213fa2e3df98196e47 to your computer and use it in GitHub Desktop.
Gradle SSH Env Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
repositories { jcenter() } | |
dependencies { classpath 'org.hidetake:gradle-ssh-plugin:0.1.7' } | |
} | |
apply plugin: 'ssh' | |
remotes { | |
test { | |
host = '192.168.255.1' | |
user = 'deploy' | |
password = project.hasProperty('deployPwd') ? project.getProperty("deployPwd") : '' | |
} | |
prod { | |
host = '192.168.255.2' | |
user = 'deploy' | |
password = project.hasProperty('deployPwd') ? project.getProperty("deployPwd") : '' | |
} | |
} | |
task deploy() { | |
dependsOn "leinUberjar" | |
mustRunAfter "deployConfig" | |
doFirst { | |
validateEnvironment() | |
} | |
doLast { | |
sshexec { | |
session(remotes[project.env]) { | |
project.logger.info "SFTP put uberjar" | |
put leinUberjar.uberjarfile.path, "/usr/local/lib/myapp/${project.name}.jar" | |
project.logger.info "Restart service ${project.name}" | |
executeSudo("supervisorctl restart ${project.name}") | |
} | |
} | |
} | |
} | |
void validateEnvironment() { | |
assert project.hasProperty("env") && remotes[project.env], | |
"You have to provide env parameter. Allowed values: dev, test, prod" | |
} | |
//... etc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment