Jenkins can't see mapped drive
Asked Answered
S

3

5

I'm getting the following error when trying to execute a build in Jenkins:

Started by user anonymous
Building in workspace C:\Users\mryan\git\AML
[AML] $ cmd /c call C:\Users\MRYAN~1.ASA\AppData\Local\Temp\hudson3772834793680550098.bat

C:\Users\mryan\git\AML>asc-tree -v cs1 . 
Array @filter_prune missing the @ in argument 1 of push() at C:\asc\asc\win2k/asc-tree. line 293.
asc-tree.: ASC (=Z:\asc) is not a directory!
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE

When I open a normal command prompt and run the same command (asc-tree -v cs1 .), it works okay.

I had a look here and tried using UNC notation in my environment variables instead of "Z:\" but that just gave me the same error with the machine name instead of the drive.

I also tried changing the service to use my account Log On details instead of the "Local System Account" but that didn't seem to do it.

Anybody have any ideas??

Scriptwriter answered 14/7, 2014 at 9:59 Comment(0)
S
15

Following this answer, I managed to get it working.

Solution can be found in Aspera Support's article: How to map network shares into drives to a Windows service permanently.

Solution:

In order for network shares to be mapped into drives and accessible within Windows services, you need to login as the NT AUTHORITY\SYSTEM account.

To do this, download the Sysinternals Suite from Microsoft, and unzip it to a directory, say C:\TEMP The following steps assume that you've unzipped SysInternals to C:\TEMP and all the executables are in there.

  1. Launch a command prompt as Administrator.
  2. CD \TEMP
  3. psexec -i -s cmd.exe
    This launches a new command prompt window, and step 4 should be performed in that new window.
  4. net use Z: \\servername_OR_IP\sharedfolder /u:username /persistent:yes
    Provide the credentials of a user having access to the shared folder.

  5. Create a script that runs on computer startup that has only line 4 in it acccording to Microsoft's article: Assign Computer Startup scripts.

Scriptwriter answered 14/7, 2014 at 10:57 Comment(4)
The answer should be provided in full — links tend to change, sites go offline,...Berlin
I'm running into the same problem, but as you mentioned, I'm running Jenkins as service but with my user account credentials, so why the network shares are still not visible?Transpadane
This all works, except the Create a script that runs on computer startupPeddling
Didn't work for me, this answer doesn't provide enough details...Transcurrent
C
0

Faced the same issue on Windows Server 2008. Configured the correct user credentials on the Jenkins agent service and restarted it but that did not help either.

Finally what worked is to launch the agent via Java Web Start without installing it as a Windows service.

Carping answered 20/4, 2019 at 9:46 Comment(0)
B
0

not sure what the point of steps 1 to 3 are for TomSellek's answer, you only need step 4. Choose user 'system' when you create the task, in the security options.

Beckerman answered 25/6, 2021 at 14:37 Comment(1)
Which security options are you talking about? It's a command, it has the parameter /user:<username>, where one puts their username. Where is the security option supposed to fit into this?Transcurrent

© 2022 - 2024 — McMap. All rights reserved.