The system cannot find the specified drive in Jenkins

I want to copy some files from a shared network drive (mounted on my local machine as drive Z). I wrote a batch file to copy the contents of a Z-drive to a local drive. This batch file works successfully on cmd, but I have a problem when I run it through Jenkins. Jenkins gives the following error:

"The system cannot find the specified drive"

Any help on this would be greatly appreciated.

Thanks, Nouman.

+6
source share
8 answers

If you do not want to use Jenkins-plugins or schedule-Tasks, this is the "groovy" method:

Hand:

You can use the Groovy Script console provided by Jenkins> Manage Jenkins> Script Console and run the command to map a network drive in the Jenkins service. (Should be repeated as soon as the Jenkins service is stopped)

Automation:

Write your Groovy commands to a file named "init.groovy" and put it in your JENKINS_HOME directory. Thus, the network drive appears in Jenkins-startup.

Groovy Commands - Windows:

Check available network drives with Script-Console:

println "net use".execute().getText() 

Your init.groovy will look like this:

 def mapdrive = "net use z: \\\\YOUR_REMOTE_MACHINE\\SHARED_FOLDERNAME" mapdrive.execute() 
+8
source

You may run into permission problems. Jenkins can be executed with various user credentials; therefore, he does not know the configured drive for sharing Windows. Instead of using shell scripts, I suggest using a plugin. There is a set of Publish-over plugins that allow you to deploy remote systems through a couple of protocols (ssh, cfis, etc.). Check out the CFIS plugin that lets you send artifacts to a Windows share. Once the plugin is configured (i.e., the Node is listed in the "Managing the Jenkins Partition" section), you can add to the post-build steps. Send files to a Windows share where you can specify which file should be sent to which location.

+1
source

Yes, Jenkins uses different credentials. To map drives through Jenkins, use the command below on the Jenkins command line:

Substitution U: \ drive \ folder

followed by your inquiries.

+1
source

Try adding debug commands to this bat file or as a separate build step, for example net use , set (note the vars, such as HOMEPATH and USERNAME ), and the regular dir Z:\ .

As another answer says, most likely the reason is that Jenkins works as a SYSTEM user who has different permissions. One way: go to services (for example, open the task manager, go to the Services tab, click the Services button in the lower right corner of this tab), find the Jenkins service, open its properties, go to "Log on" and set a regular user account like the one that runs Jenkins.

0
source

Essentially, you can access a shared network drive (Z) using the server name or IP address from the jenkins command. Write \\192.168.x.xxx\Your_Folder instead of z:\Your_Folder .

For instance:

 mkdir \\192.168.x.xxx\Your_Folder 
0
source

I tried to copy files from one remote computer to another, a simple solution that helped me was COPY iphone.exe \ 192.xx.xx.xx \ dev (dev is the name of the folder on drive c in this IP address)

0
source

We ran into this problem when Jenkins subordinates were configured on Windows Server 2008 according to their documentation .

Having spent hours troubleshooting, we noticed that:

  1. Jenkins can access mapped network drives by the drive letters when connected through the JNLP agent (start agent via Java Web Start).
  2. It stops recognizing drive letters shortly after we install the agent as a Windows service.
  3. We could still access the disks through the command line when entering the system on machines.

In fact, do not install the slave agent as a Windows service to continue to access mapped network drives using drive letters. But this is extremely unreliable, since the agent may not reboot after rebooting the computer. Or see if Jenkins can access them through \\<ip_address\of\network\drive> .

0
source

A similar issue was found for us on Jenkins subordinates configured on Windows Server 2008, following this documentation . Jenkins Agent was unable to access the mapped network drives even after setting up the agent service with the correct user credentials.

Problem Finder:

  1. Jenkins can access mapped network drives by the drive letters when connected through the JNLP agent (start agent via Java Web Start).
  2. It stops recognizing drive letters shortly after we install the agent as a Windows service. Setting the correct user credentials and restarting the agent does not help.
  3. We can still access the drives through the command line when we log in with the specified user.
  4. Stop the agent service from services.msc and then uninstall it by running jenkins-slave.exe uninstall> . The slave is currently disabled.
  5. Reconnect the slave by starting the JNLP agent through Java Web Start. Now the agent can again access network drives.

Summary:

Do not install the slave agent as a Windows service to continue to access mapped network drives using drive letters. But this is extremely unreliable, since the agent may not reboot after rebooting the computer. Or see if Jenkins can access them through \\<ip_address\of\network\drive> .

0
source

All Articles