FTP Deployment

Semaphore has LFTP, an FTP/HTTP client and a file transfer program, installed by default. LFTP can be used with the Generic Deployment method on Semaphore.

Configuring FTP deployment

The first step is to create 2 environment variables that will allow LFTP to access your server. Visit the project settings environment variables tab and create 2 new environment variables, FTP_USER and FTP_PASSWORD. Feel free to encrypt the FTP_PASSWORD variable.

Environment Variables

Next, go to the dashboard and press “Set Up Deployment” button for that project.

Setup Deployment

Choose the Generic Deployment method.

Generic Deployment

The next step is choosing your deployment strategy. Semaphore supports two deployment strategies, Automatic and Manual. You can read more about them here.

Select Strategy

If you choose the automatic deployment strategy, you need to select the branch that will be automatically deployed.

Select Branch

After that, you need to set the commands that will perform the deploy. With LFTP, you can deploy your application using a single line:

lftp -c "open -u $FTP_USER,$FTP_PASSWORD YOUR_FTP_HOST; set ssl:verify-certificate no; mirror -R ./ YOUR_REMOTE_PATH"

Copy the line and paste it in the deploy commands text area.

Here, $FTP_USER and $FTP_PASSWORD are environment variables that we previously defined.

Replace YOUR_FTP_HOST and YOUR_REMOTE_PATH with corresponding values.

Deploy Commands

Next, set a meaningful name for the new deployment target.

Server Name

After that, FTP deployment is fully configured. You can trigger the first deploy manually right from the new server page.

First FTP Deploy