Runner can't copy to network share

I am currently trying to setup a CI-Runner for my Gitlab CE instance. I am mostly doing C# project so my runner host is a windows machine hosting a shell runner. Compiling and testing with NUnit was a charm to set up and works completely as exspected. But now I want to test how a deploy to a network share could look like.

I try to copy just a simple compiled exe to a network drive. To preserve this compiled exe I did configure it as an artifact. So the dependent deploy job could download it and deploy it.
Executing the command from the project root in a console works without any problems. However everytime the runner executes the command it fails telling me it can’t the networkshare path/file.

By searching around I stumbled upon a stackoverflow post regarding the same issue. Sadly there is no helpful information to solve the problem yet.

My .gitlab-ci-yml:

    - build
    - test
    - deploy
    SLN_NAME: gitlab-ci-test
    SLN: gitlab-ci-test.sln
    PROJECT1_NAME: gitlab-ci-test
    PROJECT1_PROJ: gitlab-ci-test/gitlab-ci-test.csproj
    PROJECT1_TEST_NAME: gitlab-ci-test.Tests
    PROJECT1_TEST_PROJ: gitlab-ci-test.Tests/gitlab-ci-test.Tests.csproj
    NUGET: 'D:/Gitlab-Runner/bin/nuget/nuget.exe'
    NUNIT_CONSOLE: 'D:/Gitlab-Runner/bin/nunit/nunit3-console.exe'
    MSBUILD: 'D:/Gitlab-Runner/bin/msbuildtools/MSBuild/15.0/Bin/msbuild.exe'
    CYGWIN: 'D:/Gitlab-Runner/bin/cygwin64/'
    stage: build
        expire_in: '5 mins'
            - '%PROJECT1_NAME%/bin/Release/'
        - '%NUGET% restore "%PROJECT1_PROJ%" -SolutionDirectory .\'
        - '"%MSBUILD%" /property:Configuration=Release /verbosity:quiet "%PROJECT1_PROJ%"'
    stage: build
        expire_in: '5 mins'
            - '%PROJECT1_TEST_NAME%/bin/Release/'
        - '%NUGET% restore "%PROJECT1_TEST_PROJ%" -SolutionDirectory .\'
        - '"%MSBUILD%" /property:Configuration=Release /verbosity:quiet "%PROJECT1_TEST_PROJ%"'
    stage: test
        - build_gitlab-ci-test.Tests
        - '%NUNIT_CONSOLE% "%PROJECT1_TEST_NAME%/bin/Release/%PROJECT1_TEST_NAME%.dll"'
    stage: deploy
        - build_gitlab-ci-test
        - '%CYGWIN%/cp "%PROJECT1_NAME%/bin/Release/gitlab-ci-test.exe" "J:/BeR/Deploy/gitlab-ci-test/gitlab-ci-test.exe"'

The build and test stages are finishing without any errors.

Output of the deploy_gitlab-ci-test job:

Running with gitlab-runner 11.3.1~beta.4.g0aa5179e (0aa5179e)
on PC-BER 01e8cc91
Using Shell executor…
Running on PC-BER…
Fetching changes…
Removing TestResult.xml
Removing gitlab-ci-test.Tests/bin/
HEAD is now at 50aa69a ???
Checking out 50aa69a7 as master…
Skipping Git submodules setup
Downloading artifacts for build_gitlab-ci-test (103)…
Downloading artifacts from coordinator… ok id=103 responseStatus=200 OK token=zkm3SGEh
$ %CYGWIN%/cp “%PROJECT1_NAME%/bin/Release/gitlab-ci-test.exe” “J:/BeR/Deploy/gitlab-ci-test/gitlab-ci-test.exe”
/cygwin64/cp: cannot create regular file ‘J:/BeR/Deploy/gitlab-ci-test/gitlab-ci-test.exe’: No such file or directory
ERROR: Job failed: exit status 1

Is this a known problem or does anyone know a workaround?

1 Like

Since you’re using cygwin64, you’re obviously on a Windows runner, so how about you set Environment Variables in your project with a Username and Password to the share:

  • NETWORK_USER … if domain is required, be sure to include it; see net use /? for details.

Then use the following lines before you copy to first authenticate the connection:

net use \\computername\sharename\volume /USER:%NETWORK_USER% %NETWORK_PASS%

Keep in mind that since it’s running this in bash/cygwin, you’ll need to bashify things a bit:

net.exe use \\\\computername\\sharename\\volume /USER:${NETWORK_USER} ${NETWORK_PASS}