Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Sync with ftp-deploy

pk86 July 2, 2022

Hi guys, I need a little assistance with my pipeline for deploy on ftp server.

I tried this pipeline:

image: wagnerstephan/bitbucket-git-ftp:latest

pipelines:
default:
- step:
script:
- echo "This script runs on all branches that don't have any specific pipeline assigned in 'branches'."
branches:
master:
- step:
name: Test
deployment: production
script:
- git reset --hard
#- git ftp init -u "$FTP_USERNAME" -p "$FTP_PASSWORD" ftp://$FTP_HOST
- pipe: atlassian/ftp-deploy:0.3.7
variables:
USER: $FTP_USERNAME
PASSWORD: $FTP_PASSWORD
SERVER: $FTP_HOST
REMOTE_PATH: /test/my-remote-directory
EXTRA_ARGS: "--only-newer --exclude=bitbucket-pipelines.yml"
caches:
- composer

 

But for each deploy all file are overwritten. --only-newer option don't works, I think because every time git pull update the files date and overwrite existings.

Can I upload only new files (by size for example) or uplaod only changes from last commit?

I can't use rsync because my target server don't has ssh but only ftp.

Thanks & regards

2 answers

1 accepted

0 votes
Answer accepted
Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 6, 2022

Hey @pk86 

Welcome to the community.

The option you use "--only-newer" is invalid because FTP deploys everything from the folder you've specified and does not consider what has changed. It simply overrides whatever's on the destination and pushes everything again.

As workaround, you can use Git FTP which should do what you want where it will upload the recent files change/commit only.

I hope this helps.

Cheers,
Syahrul

pk86 July 9, 2022

Thanks for the answer, I will try following this tutorial https://stephanwagner.me/deploy-websites-with-bitbucket-pipelines-and-git-ftp

0 votes
pk86 July 9, 2022

Thanks so much for the solution. I share my script solution if it can be helpfull for somebody else.

# Official docs git-ftp: https://github.com/git-ftp/git-ftp/blob/master/man/git-ftp.1.md
image: wagnerstephan/bitbucket-git-ftp:latest

pipelines:
custom:
init:
- step:
name: For upload all files
script:
- git reset --hard
- git ftp init -u "$FTP_USERNAME" -p "$FTP_PASSWORD" ftp://$FTP_HOST --remote-root $FTP_REMOTE_ROOT
catchup:
- step:
name: For set that all files on server are already updated
script:
- git reset --hard
- git ftp catchup -u "$FTP_USERNAME" -p "$FTP_PASSWORD" ftp://$FTP_HOST --remote-root $FTP_REMOTE_ROOT
deploy:
- step:
name: Deploy all files of current checkout
script:
- git reset --hard
- git ftp push -u "$FTP_USERNAME" -p "$FTP_PASSWORD" ftp://$FTP_HOST --all --remote-root $FTP_REMOTE_ROOT
branches:
master:
- step:
name: Deploy production
deployment: production
script:
- git reset --hard
- git ftp push -u "$FTP_USERNAME" -p "$FTP_PASSWORD" ftp://$FTP_HOST --remote-root $FTP_REMOTE_ROOT

 

If you need to exlude some file, you can declate them on .git-ftp-ignore

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events