0
votes

I want Jenkins (running on a Linux server) to run a .ps1 script on a separate Windows server. I create a new Jenkins job and choose "Execute Windows batch command." No matter what batch code I run, I get:

FATAL: command execution failed java.io.IOException: Cannot run program "cmd" ...

1
When Jenkins uses "Execute Windows batch command" it creates a temporary batch file and attempts to start the windows command prompt and run that file. Understandably the windows command prompt doesn't exist on your linux box. I'd have to do more digging to figure out what you need to do to remotely start a powershell job on a windows server from a linux server, but I would be surprised if a utility didn't already exist. You should look for something that does this that's already native to your linux environment. - Tuffwer

1 Answers

1
votes

You have a few options

  1. select Execute shell option if you want to run Unix/Linux commands. Execute windows batch command works only on Windows platform. Then from unix shell you can open secure shell to windows and run windows script.
  2. If you don't have that option, you might have to install this plugin.
    https://wiki.jenkins-ci.org/display/JENKINS/XShell+Plugin Then you can run a script to run remote commands on windows server with ssh.
  3. Alternatively you can install run commands directly on windows from jenkins.
    https://wiki.jenkins-ci.org/display/JENKINS/SSH+plugin

  4. Another option would be to install powershell plugin and configure which is described here.
    http://jenkinsheaven.blogspot.com/2015/09/jenkins-and-powershell-remoting-on.html?_sm_au_=iVV5rRssVFqBqMTH