Search code examples
linuxftpbitbucketbitbucket-pipelineslftp

Linux LFTP connecting and mirroring folder over FTPS without certificate verification on bitbucket pipelines


I've been trying to deploy my dist folder via bitbucket pipelines + lftp for quite a while now. I've tried various variations of the linux commands and gone through a couple dozen articles on the issue yet I still can't get the thing to work.

So far my pipeline commands look like this:

  - apt-get update
  - apt-get install lftp
  - lftp set ssl:verify-certificate no
  - lftp $FTP_HOST
  - user $FTP_USER
  - $FTP_PASSWORD
  - ls
  - quit

But for set I'm getting 'lftp: set: Name or service not known' -- when I delete the step it gets to user and I'm getting bash: user: command not found if I add lftp in front of it I'm getting lftp: user: Name or service not known

I think in total I've tried over 30+ times to get these right with no luck.


Solution

  • I have no complete solution as I don't know bitbucket, but I see clearly one mistake:

    You cannot change lftp settings in subsequent command calls. That's what you are actually doing:

    1. You invoke lftp with wrong command line arguments set ssl:verify-certificate no.
    2. lftp quits with error message set: Name or service not known. Even if you would have gotten the setting inside lftp in step 1 it would be cleared now because of the quit.
    3. You invoke lftp with (probably) right command line argument '$FTP_HOST'.
    4. Now 'lftp' quits, probably because it gets no commands on stdin.
    5. You mean to go all the other commands (user, password, ls, quit) to go to lftp as stdin, but according to the logs they are treated as further shell commands.

    So please look how to send stdin to a program with bitbucket. (For information on stdin: it is refered to as "input" in following tutorial which explains how shell works: http://tldp.org/LDP/Bash-Beginners-Guide/html/Bash-Beginners-Guide.html#sect_01_03 )