Copy local files to a Samba share on Travis
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

I am trying to set up continuous deployment for my static Jekyll site. The code is hosted on GitHub and I have set up Travis to build the site on every commit. The last step, the one I need help with, is to use Travis to deploy the website. The challenge is that I need to deploy my site to a Samba share. I have the URL for the share, which looks like this:

smb://storage01.example.edu/w3cognition$

I also have a username and password.

The static site is in a local (to Travis) directory called _site.

Question:

What do I need to put in my .travis.yml to copy the _site folder to the Samba network share?

awarded to slr

Crowdsource coding tasks.

2 Solutions

Winning solution

try cURL (it supports SMB/CIFS protocol since version 7.40):

after_success:
  - find "_site" -type f -exec curl -T {} -u "domain\username:passwd" "smb://storage01.example.edu/w3cognition$/" \;

set your actual credentials to "domain\username:passwd"

Three comments:
  1. When I run this, I get the following error: curl: (3) URL using bad/illegal format or missing URL I can reproduce this error locally.
  2. What does domain refer to in the above solution? example.edu or the string domain or something else?
  3. A $5 tip is available for updating the solution to use a username and passwd that are stored in environment variables.
suchow 8 months ago
  1. it seems the trailing slash is needed in "smb://storage01.example.edu/w3cognition$". the solution was edited.
  2. that's the user workgroup name and it may be omitted if it isn't specified on the server.
  3. just replace username and passwd in "domain\username:passwd" with your $USER and $PWD variables.
you may find the solution still does not work and falls with curl: (67) Login denied. that's because of cURL broken NTLM v2 Authentication or something like that. try smbclient solution in this case.
slr 8 months ago

after_success:
  - smbclient //storage01.example.edu/w3cognition$ -U username password -c 'prompt OFF; recurse ON; mput _site'

of course you may replace username and password with your predefined $USER and $PWD variables

View Timeline