I've got a continuous integration server (Jenkins ) which builds my code (checks for compilation errors) and runs tests and then deploys the files to a remote server (not a war file, but the actual file structure) I do this with a Jenkins plugin which allows me to transfer files via samba, it does this nightly.
Now, what I need to do is run an ant command on the remote server. And after that I need to start the application server on the remote server, the application server is started by running a .bat file from the command line.
I'm pretty clueless how to accomplish this, I know Jenkins is capable of running batch commands, but how do I make them run in the context of the server and not the context of the build server?
If Jenkins on Windows, remote on *nix, use
plink.exe
(which is essentially command linePuTTy
)If Jenkins on Windows, remote on Window, use
psexec.exe
If Jenkins on *nix, remote on *nix, use
ssh
If Jenkins on *nix, remote on Windows, (update 2015-01) Ansible http://docs.ansible.com/intro_windows.html has support for calling Windows commands, eg powershell, from a unix/linux machine, https://github.com/ansible/ansible-examples/blob/master/windows/run-powershell.yml
Tell me what OSes are involved (both on Jenkins and remote), and I will flash this out further.
Edit:
The download page for
psexec.exe
lists all command line options. You will want something along the lines of:psexec \\remotecomputername -u remoteusername -p remotepassword cmd /c <your commands here>
Replace
<your commands here>
with actual commands as you would execute them from command prompt.Note that
psexec
first needs to install a service, and required elevated command prompt/admin remote credentials to do so.Also, you need to run
psexec -accepteula
once to accept the EULA prompt.I ended up going with a different approach after trying out psexec.exe for a while.
Psexec.exe and copying files over the network was a bit slow and unstable, especially since the domain I work on has a policy of changing password every months (which broke the build).
In the end I went with the master/slave approach, which is faster and more stable. Since I don't have to use psexec.exe and don't have to copy files over the network.
Following Slav's answer above, here is a simpler solution for Jenkins (*nix) to remote (windows):
Notes :