Execute windows batch command from Jenkins fails but runs fine in cmd.exe

Chris picture Chris · Jun 8, 2012 · Viewed 75.2k times · Source

I am trying to run this command in jenkins after a MSbuild

xcopy "C:\Program Files (x86)\Jenkins\workspace\trunk\Projects\results\results\obj\Debug\Package\PackageTmp" "Y:\Extraction_Zone\Jenkins\" /E 

Y: is a mapped network drive. This runs fine in cmd.exe but when trying to run it in Jenkins, I am getting the error Invalid drive specification.

Here is the output from jenkins:

Time Elapsed 00:00:04.03
[trunk] $ cmd /c call C:\Windows\TEMP\hudson3389873107474371072.bat

C:\Program Files (x86)\Jenkins\workspace\trunk>xcopy "C:\Program Files (x86)\Jenkins\workspace\trunk\Projects\results\results\obj\Debug\Package\PackageTmp" "Y:\Extraction_Zone\Jenkins\" /E 
Invalid drive specification
0 File(s) copied

C:\Program Files (x86)\Jenkins\workspace\trunk>exit 4 
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE

Any help would be appreciated.

Answer

adarshr picture adarshr · Jun 8, 2012

I too had a similar issue once. Try granting the Jenkins service "Logon as This account" right under services.msc and make sure the account you type there is the same as the one you use for running cmd.exe.

enter image description here