Dean Chen
Dean Chen

Reputation: 3890

Jenkins can't access mounted driver

My Jenkins server is running in Tomcat on Windows 2008 server. I have set up a NFS server on CentOS, Win2008 server can access the NFS shared folder via mount command. I tested it when running as administrator user on Windows. I mount the folder as Z driver on Windows 2008 server. But my job in Jenkins said it can't find the Z driver, I guess Jenkins web app might have not the enough permission to access Z driver. Please see the error message from Jenkins

Console output:

Started by user anonymous
Building in workspace C:\.jenkins\workspace\upland-install
[upland-install] $ cmd /c call "C:\Program Files\Apache Software Foundation\Tomcat    6.0\temp\hudson4487584210513580576.bat"

C:\.jenkins\workspace\upland-install>rd d:\tmp\upland_dist /s /q 

C:\.jenkins\workspace\upland-install>xcopy Z:\upland_release\364 d:\tmp /S

 **Invalid drive specification**
 0 File(s) copied

How to fix this problem? Install Jenkins as a windows service?

Upvotes: 5

Views: 17912

Answers (5)

Dibakar Aditya
Dibakar Aditya

Reputation: 4203

Same issue here on Windows Server 2008 R2.

What did the trick for us is to launch the agent via Java Web Start on the slave machine but not install it as a Windows service. Though this trick will not automatically restore the connection after machine reboots.

Strangely enough, installing the agent as a Windows service and configuring it with the correct user credentials did not work for us even after service restarts and successful reconnections.

Upvotes: 0

domih
domih

Reputation: 1578

Accessing files on a remote share directly from Jenkins can be tricky as it probably returns access denied. To fix this, configure the Jenkins service to run as a user.

In my case I want to output (type "\\slave1\log\ui.log" ) a log file from UI tests on a Jenkins slave to Jenkins master, to retain it on the build log. Without this, if a test fails, and another build overwrites the faillog, the root cause could not be determined. By copying the log output to Jenkins, the build failure can be reproduced every time later.

To switch the user of the Jenkins service, open mmc, add "Services" snap-in, find Jenkins Service, double click it and set user and password on the authentication tab.

HTH

Upvotes: 0

Pranjay Kaparuwan
Pranjay Kaparuwan

Reputation: 921

go to the job --> open execute window cammand script and write

subst X: \folder\folder2

after that run your task. the above will map your drive

Upvotes: 0

wgrant
wgrant

Reputation: 175

I can't [yet] comment, otherwise I would tell Anders Lindahl to make his suggestion an answer. I was having this exact issue and the suggestion to mount the shared drive as a build step allowed me to use the ArtifactDeployer plugin to successfully copy to the network drive.

I inserted a build step of 'Execute batch command' and typed in:

net use J: \\example.com\path\to\share

Note, my setup is Jenkins running as local system account. And a jnlp slave node installed as a windows service using a domain account which has permissions to mount the network drive.

Upvotes: 2

Jason Swager
Jason Swager

Reputation: 6501

A couple solutions:

  1. You need to run your Jenkins process in the same user context that you mounted the drive in. This works, but isn't always the desired solution.
  2. Run the job on a Jenkins slave that is started in the context of the user with the mounted drive. Not always possible if slave machines aren't available.
  3. Use the Publish Over CIFS plugin

Upvotes: 5

Related Questions