README.md

grunt-ftp-deploy

These days git is not only our goto code management tool but in many cases our deployment tool as well. But there are many cases where git is not really fit for deployment:

we deploy to servers with only ftp access

the production code is a result of a build process producing files that we do not necessarily track with git

This is why a grunt task like this would be very useful.

For simplicity purposes this task avoids deleting any files and it is not trying to do any size or time stamp comparison. It simply transfers all the files (and folder structure) from your dev / build location to a location on your server.

Getting Started

This plugin requires Grunt ~0.4.0

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-ftp-deploy --save-dev

and load the task:

grunt.loadNpmTasks('grunt-ftp-deploy');

Usage

To use this task you will need to include the following configuration in your grunt file:

Please note that when defining paths for sources, destinations, exclusions e.t.c they need to be defined having the root of the project as a reference point.

The parameters in our configuration are:

host - the name or the IP address of the server we are deploying to

port - the port that the ftp service is running on

authPath - an optional path to a file with credentials that defaults to .ftppass in the project folder if not provided

authKey - a key for looking up credentials saved in a file (see next section). If no value is defined, the host parameter will be used

src - the source location, the local folder that we are transferring to the server

dest - the destination location, the folder on the server we are deploying to

exclusions - an optional parameter allowing us to exclude files and folders by utilizing grunt's support for minimatch. The matchBase minimatch option is enabled, so .git* would match the path /foo/bar/.gitignore.

forceVerbose - if set to true forces the output verbosity.

Authentication parameters

Usernames and passwords can be stored in an optional JSON file (.ftppass in the project folder or optionaly defined inauthPath). The credentials file should have the following format: