Expected behaviour from "lftp mirror" but "lftp put" doesn't work

Hi everyone,

It’s good to be part of the community!

I’m very new to CI and Linux commands. I have recently slowly tried to find my way around and produce a .yml script that satisfies my use case.

I am publishing a .NET Core application, zipping the result and uploading it to my Ubuntu 18.04.2 x64’s ftp, configured with vsftp.

I am using lftp’s put command to perform the upload.

Here is my .gitlab-ci.yml file:

image: microsoft/dotnet:latest

    - build
    - test
    - deploy
    publishdir: "bin\\release\\"

    stage: build
        - "dotnet build"
        - bin/

    stage: test
        - "dotnet test"
    stage: deploy
        deploy_path: "src/App/"
    # cd to where the project is
    - cd $deploy_path
    # publish the files - this will generate the publish files in bin/release 
    - dotnet publish -c release
    # install zip
    - apt-get update -qq && apt-get install -y -qq zip
    # cd to /bin
    - cd bin
    # zip release, name zip Project.zip
    - zip -r Project.zip release
    # install lftp
    # - apt-get update -qq && apt-get install -y -qq lftp
    # upload file to ftp
    - lftp -e "set ssl:verify-certificate no; open $FTP_HOST; user $FTP_USERNAME $FTP_PASSWORD; put -O /files Project.zip; bye"
    - dev

Everything seems to work well up to the lftp command where although the pipeline is successful, the file has not been transferred and the target ftp directory “files” is empty.

If I replace “put” with “mirror” and use the following statement, it works fine:

- lftp -e "set ssl:verify-certificate no; open $FTP_HOST;; user $FTP_USERNAME $FTP_PASSWORD; mirror -X .* -X .*/ --reverse --verbose --only-newer --no-symlinks bin /files; bye"

However, “put” in this case seems much more appropriate and optimised for a single file rather than mirroring the contents of an entire directory.

I’ve searched far and wide and am unable to see anything that could be wrong with my code.

Thanks a lot for your help in case you notice something!

1 Like