Question

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.

Was it helpful?

Solution 2

OTHER TIPS

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.

Try this , this will work

"D:\Temp\PsTools\PsExec.exe" \\\\remoteMachine -u username -p password /accepteula -h cmd /c "C:\remotescript.bat"

try couple things...

  1. add parameter option 0 after the accepteula in your command that should kills any existing psexec process which is hung up and start processing your psexec

  2. verify the machine for 32-bit or 64-bit..

    for 64-bit the psexec is searched in C:\Windows\system32
    for 32-bit the psexec is searched in C:\Windows\SysWOW64

in jenkins job you can set msbuild version to 64 BIT or 32 BIT accordingly and it should work as expected.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top