The system cannot find the specified drive in Jenkins
Solution 1
If you don't want to use Jenkins-plugins or schedule-Tasks here is a "groovy" way:
By Hand:
You can use the Groovy Script-Console provided by Jenkins>Manage Jenkins>Script Console and execute the command to map the network-drive within the Jenkins-service. (Must be repeated, once the Jenkins-service is stopped)
Automation:
Write your Groovy commands to a file named "init.groovy" and place it in your JENKINS_HOME-directory. So the network-drive gets mapped on Jenkins-startup.
Groovy Commands - Windows:
Check available network drives using the Script-Console:
println "net use".execute().getText()
Your init.groovy would look like this:
def mapdrive = "net use z: \\\\YOUR_REMOTE_MACHINE\\SHARED_FOLDERNAME"
mapdrive.execute()
Solution 2
Yes Jenkins uses different login credentials. To map a drives through Jenkins use below command in Jenkins command prompt:
Subst U: \drive\folder
then after that your queries.
Solution 3
You might run into permission issues. Jenkins might be executed with different user credentials; so it does not know the configured drive for the windows share. Instead of using shell scripts I suggest to use a plugin. There is a set of Publish-over plugins that allow deployments to remote systems via a couple of protocols (ssh, cfis etc). Have a look at the CFIS plugin that allows to send artifacts to a windows share. Once the plugin is configured (ie the host is specified in the Manage Jenkins section) you can add to the post build steps Send files to a windows share where you can specify which file(s) shall be sent to which location.
Nomi Khan
Updated on July 20, 2022Comments
-
Nomi Khan almost 2 years
I want to copy some files from a network shared drive (mounted at my local machine as drive Z). I have written a Batch file to copy the contents of Z drive into my local drive. This batch file runs successfully on cmd, but i am having issue when i trigger it through Jenkins. The Jenkins gives the following error:
"The system cannot find the specified drive"
Any help regarding this, will be greatly appreciated.
Thanks, Nouman.
-
jwernerny over 11 yearsIf you are running Jenkins as a Windows Service, then it is running as user "NT AUTHORITY\SYSTEM", which will most likely have different settings, permissions, etc then you or a regular user. To see how your batch file will execute from a cmd shell of your own, refer to the question How to run commands as NT AUTHORITY... on serverfault.
-
Garen almost 11 yearsNice, I wasn't aware of these. Sadly, in my case I need to dynamically fetch a free drive letter, and then assign it to a newly-created UNC path (ClearCase view) that's created at run-time. Problem is, any build-step that needs the mapping has to repeatedly re-map the drive manually in every "Execute Windows Batch Command" build-step.
-
Garen almost 11 yearsJenkins allows the service to run with a specified user/password in the node configuration.
-
Brian about 5 yearsHow would you map two different drives?
-
Cthutu almost 5 yearsI would add that you need to make sure that you have C:\Windows\System32 added to the PATH environment variable, which you need to add to: Jenkins > Manage Jenkins > Configure System.