I have a gitlab-ci.yml which builds a project and should deploy it to a windows share, but the second stage where I mount a windows share does not work inside my runner.
I have a windows machine with Docker Desktop installed and started the runner.
Mounting the share when starting the container and mounting manually works fine like this
docker run -it --cap-add=SYS_ADMIN --cap-add=DAC_READ_SEARCH --rm myimagefromnexus:latest
apt-get update && apt-get install -y smbclient
mkdir -p /mnt/windows_share
mount -t cifs -o username=myuser,password=pwwithspecialchar\$\!,workgroup=mygrp,dir_mode=0777,file_mode=0666 //serverpany.at/sharename\$/Test /mnt/windows_share
whats special here is, that the sharename and password can contain a special character, but these are correctly escaped.
this is my config.toml for my runner
[runners.docker]
cap_add = ["SYS_ADMIN", "DAC_READ_SEARCH"]
tls_verify = false
image = "myimagefromnexus:latest"
privileged = true / false neither works
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/cache"]
shm_size = 0
network_mtu = 0
and this is my gitlab-ci.yml
image: myimagefromnexus:latest
stages:
- build
- deploy
variables:
BUILD_DIR: "bin/Release"
PROJECT_FILE: "project.csproj"
SHARE_PATH: "$SHARE_PATH_STAGE"
MOUNT_DIR: "/mnt/windows_share"
before_script:
- echo "Running before_script..."
- apt-get update && apt-get install -y smbclient
- echo "smbclient installed"
build:
stage: build
script:
- dotnet build "$PROJECT_FILE" --configuration Release
- |
echo "Mounting $SHARE_PATH to $MOUNT_DIR with user $WINDOWS_USER..."
artifacts:
paths:
- $BUILD_DIR
deploy:
stage: deploy
script:
- echo "Mounting $SHARE_PATH to $MOUNT_DIR with user $WINDOWS_SHARE_USER and copy
content of $BUILD_DIR..."
- |
pwd
cat /proc/self/status | grep NoNewPrivs
if [[ "$CI_COMMIT_BRANCH" == "main" ]]; then
echo "Deploying to production..."
else
echo "Deploying to stage..."
fi
echo "Mounting $SHARE_PATH to $MOUNT_DIR with user $WINDOWS_SHARE_USER..."
if findmnt --target "$MOUNT_DIR" > /dev/null; then
echo "Unmounting existing mount at $MOUNT_DIR"
umount $MOUNT_DIR
fi
if [[ ! -d "$MOUNT_DIR" ]]; then
mkdir -p "$MOUNT_DIR"
else
echo "$MOUNT_DIR already exists"
fi
if ! mount | grep -q "$SHARE_PATH"; then
echo "Mounting $SHARE_PATH to $MOUNT_DIR with user $WINDOWS_SHARE_USER..."
mount -t cifs -v -o username=$WINDOWS_SHARE_USER,password=$WINDOWS_SHARE_USER_PASSWORD,workgroup=mygrp,dir_mode=0777,file_mode=0666,vers=3.0 $SHARE_PATH $MOUNT_DIR
else
echo "$SHARE_PATH is already mounted."
fi
echo "Mount failed with exit code: $?"
mount | grep cifs
echo "Copying files from $BUILD_DIR to $MOUNT_DIR..."
cp -r $BUILD_DIR/* $MOUNT_DIR/ || { echo "Failed to copy files"; exit 1; }
echo "Files copied successfully to $MOUNT_DIR"
only:
- branches
dependencies:
- build
which results in the following error in my runner
mount error(13): Permission denied
Thank you for your help