Using Gitlab to deploy using FTP
The aim is for modications on a project’s master branch to be deployed across to a server using the SFTP protocol. A limitation of this particular set-up is that it requires gitlab-runner
to be running locally on your machine to process the task.
Prerequisites
- Project managed with Git
- Gitlab CE / EE
gitlab-runner
tool installed on your local machine and registered with the project usingshell
as the executor.- lftp a sophisticated file transfer program
gitlab-ci.yml
stages:
- deploy
publishToMaster:
stage: deploy
script:
- lftp -e "mirror --reverse --exclude ^\.git.* --exclude \.gitlab-ci.yaml -eRv $CI_PROJECT_DIR ./; quit;" sftp://$SFTP_CREDENTIALS/$DEPLOY_DESTINATION
tags:
- local
In your project’s > Settings > Pipeline make sure to create values for SFTP_CREDENTIALS
and DEPLOY_DESTINATION
.