File is not always overwritten in the destination when using pipe atlassian/ftp-deploy
Platform Notice: Cloud Only - This article only applies to Atlassian apps on the cloud platform.
Summary
When using the pipe atlassian/ftp-deploy or lftp command directly as part of the Bitbucket pipeline build, sometimes the files are not replaced in the destination server.
Environment
Bitbucket Pipelines in Bitbucket Cloud
Diagnosis
When deploying files to a remote FTP server using atlassian/ftp-deploy pipe, or the lftp command directly, not all files are replaced in the destination server.
Cause
The atlassian/ftp-deploypipe essentially uses the lftp program using the mirror functionality. The ftp mirror algorithm looks at both the file timestamp and sizes to decide whether a file is newer or was changed and then if the file should be transferred to the destination or not. In some cases, lftp might skip the transfer of some files, even though some changes were indeed applied.
Solution
lftp mirror program provides the flag --transfer-all to be used when the user wants to force the files to be transferred/overwritten in the destination server even if there were no changes identified. This flag can be included in the EXTRA_ARGS variable of the atlassian/ftp-deploy pipe as shown in the below example :
- pipe: atlassian/ftp-deploy:0.3.7
variables:
USER: $FTP_USERNAME
PASSWORD: $FTP_PASSWORD
SERVER: $SERVER
REMOTE_PATH: /remote/path/
EXTRA_ARGS: "--transfer-all"This will force lftp program to transfer all the files to the destination and overwrite existing files.
Was this helpful?