Search code examples
pythonftptravis-cimkdocs

Travis CI only uploads empty files from the build script


I'm currently trying to set up a documentation project on Travis CI. The build script uses the mkdocs library to generate markdown files to HTML files. I've tried now many hours to automate the deploy process with Travis CI. It should generate the files directly on Travis CI and upload it then to an FTP server.

What I've tried

So I had committed this .travis.yml file to my Github repo.

language: python
python: 
  - "2.7"
env:
  global:
    #FTP_USERNAME
    - secure: "N9knL6LsuiZ....."
    #FTP_PASSWORD
    - secure: "NrRpwCeay7Y0s....."
install: 
  - pip install mkdocs
  - mkdocs --version
script:
  - mkdocs build
after_success:
  - find documentation -type f -exec curl -u "${FTP_USERNAME}:${FTP_PASSWORD}" --verbose --progress-bar --ftp-create-dirs --max-time 30 -T {} ftp://my.ftp-server.com/{} \;

The mkdocs build script does output the generated files in the root folder "documentation". Actually this code works unless the directory on the FTP server does not exist.

What does not work

I have tried the same code locally (just ran the after_success command) and there it uploads the files correctly with content. When Travis-CI now starts uploading the files to my FTP server, then it begins with the transfer but does not end it until the timeout exception will be thrown. When I check the files on the server, then it only has created empty files.

Can maybe someone help me why this problem occurs?


Solution

  • I have found now something interesting on the Travis CI Blog. They are describing, that the FTP protocol is no longer supported on a normal Travis CI environment. The fact that it uses different NATs on the deployment, makes the FTP server unsure about the requests and it will block the content requests.

    Solution

    Therefore you have to use SFTP or a VPN connection to your FTP server in order to deploy the files on Travis CI. But there are also a lot of other CI/CD solutions. I personally use now Github Actions, which works very well. There is even an FTP Upload module for that.

    This might be the reason why it does not upload the files because it writes it somewhere where the FTP server already has blocked the request.