Richard Smith's Blog

The thoughts of an easily distracted software developer...

Clearing a FTP directory with TeamCity & LFTP

I recently needed to setup a TeamCity build which deployed to an FTP site. Configuring the deployment itself was simple: just use the Deployer plugin to copy the build artifacts across.

Unfortunately the plugin doesn’t support cleaning out the destination directory before copying the artifacts. The solution was to use LFTP to run:

rm -rf /my/target/dir/*

There is a windows build of LFTP available here. You can then just configure a command line build step in TeamCity to run something like this:

lftp -u user,password -e "rm -r /my/target/dir/*; bye"