且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从 jenkins 在远程服务器(windows)上运行批处理脚本

更新时间:2023-10-21 16:46:10

如果 Jenkins 在 Windows 上,远程在 *nix 上,使用 plink.exe(本质上是命令行 PuTTy代码>)

If Jenkins on Windows, remote on *nix, use plink.exe (which is essentially command line PuTTy)

如果 Jenkins 在 Windows 上,远程在 Window 上,使用 psexec.exe代码>

If Jenkins on Windows, remote on Window, use psexec.exe

如果Jenkins在*nix上,远程在*nix上,使用ssh

If Jenkins on *nix, remote on *nix, use ssh

如果 Jenkins 在 *nix 上,在 Windows 上远程,(更新 2015-01)Ansible http://docs.ansible.com/intro_windows.html 支持从 unix/linux 机器调用 Windows 命令,例如 powershell,https://github.com/ansible/ansible-examples/blob/master/windows/run-powershell.yml

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

告诉我涉及哪些操作系统(包括 Jenkins 和远程),我会进一步说明.

Tell me what OSes are involved (both on Jenkins and remote), and I will flash this out further.


psexec.exe的下载页面> 列出所有命令行选项.你会想要一些类似的东西:


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
替换为实际命令,就像在命令提示符下执行它们一样.

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.

请注意,psexec 首先需要安装服务,并且需要提升的命令提示符/管理员远程凭据才能这样做.
此外,您需要运行一次 psexec -accepteula 以接受 EULA 提示.

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.