Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running a remote batch file using psexec through Jenkins fails

Running a remote batch file using psexec through Jenkins fails. Running the same batch file using psexec from the slave directly works without a charm.

Let me provide some more information. Jenkins and its slave are in a separate domain than our target machine.

When I run the batch file like this:

"D:\Temp\PsTools\PsExec.exe" \\<targetmachine> -u <targetdomain\targetdomainuser> -p <pwd> -accepteula  "d:\temp\remotescript.bat" arg1 arg2

directly from the slave (Remote Desktop taking over the machine and opening a command prompt) this works perfectly.

When entering it in a windows batch build step in Jenkins there is no visible output and I just see a spinner but nothing happens anymore and the build hangs queuing any other build creating a massive backlog. Apparently I get a failure audit where my Jenkins user tries to logon to the target machine however I specified a domain user with admin rights on the target machine (a domain user for the domain of the target machine).

Does anyone have any idea why the user tries to logon with any other credentials than the ones provided and why this works running it from the Jenkins-slave directly?

Or any other way of achieving this (running a batch file on the remote machine) is more than welcome.

like image 971
Guillaume Schuermans Avatar asked Feb 25 '13 22:02

Guillaume Schuermans


2 Answers

PAExec is a functional clone of PSExec and lets us see the output via Jenkins etc.

http://www.poweradmin.com/paexec/

XCmd is what we used at HP but for some reason it is not working at my current gig.

I don't know when PAExec appeared but it seems an ideal solution. Soon after discovering it (today) I nailed an intermittent problem with a very long/ involved Jenkins Deployment Pipeline.

like image 72
Paul Lockwood Avatar answered Sep 25 '22 12:09

Paul Lockwood


Try this , this will work

"D:\Temp\PsTools\PsExec.exe" \\\\remoteMachine -u username -p password /accepteula -h cmd /c "C:\remotescript.bat"
like image 20
Ashoka Avatar answered Sep 21 '22 12:09

Ashoka