Create file gitlab-ci.yml in gitlab
variables:
HOST: "yourFTPServer"
USERNAME: "yourFTPServerUsername"
PASSWORD: "yourFTPServerPassword"
deploy:
script:
- apt-get update -qq && apt-get install -y -qq lftp
- lftp -c "set ftp:ssl-allow no; open -u $USERNAME,$PASSWORD $HOST; mirror -Rnev ./ ./htdocs --ignore-time --parallel=10 --exclude-glob .git* --exclude .git/"
only:
- master
NOTE: Make sure to change host, username, password and directory name where to deploy code
Ref: https://stackoverflow.com/questions/49632077/use-gitlab-pipeline-to-push-data-to-ftpserver
Don’t add your credentials to gitlab-ci.yml. This will add your secrets to version control.
Use gitlab variables in the settings menu instead.