安装在Linux上运行的Jenkins以执行PowerShell脚本
如何设置在Linux上运行的Jenkins,使其在远程Windows Server 2008上执行PowerShell脚本而无需密码提示安装在Linux上运行的Jenkins以执行PowerShell脚本,powershell,jenkins,jenkins-plugins,windows-server-2008,Powershell,Jenkins,Jenkins Plugins,Windows Server 2008,如何设置在Linux上运行的Jenkins,使其在远程Windows Server 2008上执行PowerShell脚本而无需密码提示 Linux上的Master Jenkins/Windows上的Slave。这行吗?在Windows服务器上安装SSH服务器,并使用公钥/私钥对进行身份验证。在Linux上,您可以运行 ssh -i <private key file> user@host "command" ssh-iuser@host“命令” 在服务器上发出“命令”。编辑 一
Linux上的Master Jenkins/Windows上的Slave。这行吗?在Windows服务器上安装SSH服务器,并使用公钥/私钥对进行身份验证。在Linux上,您可以运行
ssh -i <private key file> user@host "command"
ssh-iuser@host“命令”
在服务器上发出“命令”。编辑
一个完整的编辑,因为我无法得到前面的答案工作
- 为Linux安装Powershell:李>
- 编写powershell脚本:
- 现在使用Jenkins执行一个shell:
powershell-非交互式-执行策略绕过/path/to/your/local.ps1
这就是我最终让它工作的方式。这与这个问题有什么关系?您似乎没有在Windows计算机上执行远程命令。最终的想法是在远程Windows计算机上运行该命令,这在powershell中是可能的。现在只是想让Jenkins和Powershell在Linux上工作。
$username = "username"
$secpass = ConvertTo-SecureString "password" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ($username,$secpass)
$remotepath = "c:\path\to\your.ps1"
Invoke-Command -ComputerName windowscomputer -Credential $mycreds -FilePath $remotepath