File is not always overwritten in the destination when using pipe atlassian/ftp-deploy
プラットフォームについて: Cloud のみ - この記事は、 クラウド プラットフォームのアトラシアン製品にのみ適用されます。
要約
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.
環境
- Bitbucket Pipelines in Bitbucket Cloud
診断
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.
原因
The atlassian/ftp-deploy pipe 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.
ソリューション
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.