Mapped drives are not consistently accessible with Windows Runners
Summary
Mapped drives are not consistently accessible with Windows Runners. Windows Runners that are mapped to shared drives on Windows don't always mount correctly. If you mount the drives from within the .gitlab-ci.yml
file with net use
, then the drives can be accessed but if the job is canceled, then the mount goes into a open state and cannot be remounted without restarting the Runner.
Steps to reproduce
- Install GitLab runner for Windows
- Configure your
config.toml
to include a Windows shared drive - This drive is sometimes not accessible within the runner
- Add
net use [server name] [password] /user:[user]
to the.gitlab-ci.yml
- Drive is accessible
- Run a pipeline with the shared drive and cancel while it's still running and the drive is in use
- Re-run the pipeline and the shared drive will throw 'System Error 85'
Example mounted drive:
共有ドライブ(Guest側はX:でマウント)
OK Y: \\<Windows-Server>\Gitlab-Runner
Microsoft Windows Network
.gitlab-ci.yml
variables:
nuget: 'c:\nuget\bin\nuget.exe'
devenv: 'C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\devenv.exe'
stages:
- build
build:
rules:
- allow_failure: true
stage: deploy
script:
- net use
- net use "Y:" \\Windows-Server\Gitlab-Runner pass /user:<ad-domain>\kmse
- echo 'Example'
- Deploy\Example_script.bat && net use /delete "Y:"
Actual behavior
Drive becomes inaccessible until the GitLab Runner for Windows is rebooted
Expected behavior
The drive access is closed when the pipeline is run
Relevant logs and/or screenshots
job log
Add the job log
Environment description
config.toml contents
Add your configuration here
Used GitLab Runner version
Possible fixes
The current workaround is to try to delete the shared drive using net use
at the beginning of the job.
Edited by Matthew Badeau