skip to Main Content

I have a Gitlab runner that runs all kind of jobs using Docker executors (host is Ubuntu 20, guests are various Linux images). The runner runs containers as unprivileged.

I am stumped on an apparently simple requirement – I need to deploy some artifacts on a Windows machine that exposes the target path as an authenticated share (\myservermyapp). Nothing more than replacing files on the target with the ones on the source – a simple rsync would be fine.

Gitlab Runner does not allow specifying mounts in the CI config (see https://gitlab.com/gitlab-org/gitlab-runner/-/issues/28121), so I tried using mount.cifs, but I discovered that by default Docker does not allow mounting anything inside the container unless running privileged, which I would like to avoid.

I also tried the suggestion to use --cap-add as described at Mount SMB/CIFS share within a Docker container but they do not seem to be enough for my host, there are probably other required capabilities and I have no idea how to identify them. Also, this looks just slightly less ugly than running privileged.

Now, I do not strictly need to mount the remote folder – if there were an SMB-aware rsync command for example I would be more than happy to use that. Unfortunately I cannot install or run anything on the Windows machine (no SSH, no SCP, no FTP), I have to use the file share mechanism.

Do you have any idea on how achieve this?

2

Answers


  1. Unfortunately I cannot install anything on the Windows machine (no SSH, no SCP, no FTP).

    You could simply copy an executable (that you can build anywhere else) in Go, listening to a port, ready to receive a file.
    This this implementation for instance: file-receive.go. It listens on port 8080 (can be changed) and copies the file content to a local folder.

    No installation or setup required: just copy the exe to the target machine and run it.

    From your GitLab runner, you can curl‘ send a file to the remote PC machine, port 8080.

    Login or Signup to reply.
  2. You can use smbclient to copy files from or to a CIFS/Samba/SMB share without creating a mount:

    smbclient '//myfileserver.domain.tld/sharename' --directory dir1/subdir1 -c 'put /path/to/local/file' -U '<USERNAME>%<PASSWORD>' -W <DOMAIN_WORKGROUP>
    

    put will copy a local file to the remote share and get will copy a remote file from the share to your local system.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search