deploy the local project via SSH
This plugin requires Grunt ~0.4.1
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-ssh-deploy --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-ssh-deploy');
Your remote server target folder for deployment has following layout:
/path/to/deploy +
|
|- current -> symlink to ./releases/<timestamp> #last deployment
|
|- releases +
|-<timestamp1>
|
|-<timestamp2>
Please create a folder named mkdir releases
under your deploy target folder. A setup task is not yet provided.
In your project's Gruntfile, add a section named deploy
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
deploy: {
liveservers: {
options:{
servers: [{
host: '123.123.123.12',
port: 22,
// usage with user/password authentication
username: 'username',
password: 'password'
// usage with SSH Agent forwarding
agent: process.env.SSH_AUTH_SOCK
}],
cmds_before_deploy: ["some cmds you may want to exec before deploy"],
cmds_warmup: ["some cmds to be executed before symlink is switched to new deployment result"],
cmds_after_deploy: ["forever restart", "some other cmds you want to exec after deploy"],
deploy_path: '/path/to/deployment',
// list of folders and files that should be excluded from deployment
exclude_list: ['./node_modules/*', './private']
}
}
},
})
###Current Execution Order
- create new folder under releases/
- zip local project folder with exclude parameters
- upload tgz file to remote
- execute warmup commands on remote machine etc. restarting services, delete fragments
- switch symlinks to new folder
- execute local cleanup
- execute post commands on remote host
- close connection
###Authentication currenty password authentication via username and password and agent SSH agent forwarding is possible. With SSH agent forwarding your personal keys can be used for authentication but host aliases are currently not supported Please see documentation of node-SSH2 plugin.
You can have a look inside every step that is executed by using grunt deploy --debug
All local and remote STDOUT and STDERR output will be shown on the console.
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.