安装Jenkins在Linux上运行以执行PowerShell脚本

问题描述:

如何设置在Linux上运行的Jenkins以在没有密码提示的情况下在远程Windows Server 2008上执行PowerShell脚本。安装Jenkins在Linux上运行以执行PowerShell脚本

在Linux上的Linux/Slave上的Jenkins大师。这会工作吗?

在Windows服务器上安装SSH服务器,并使用公钥/私钥对进行身份验证。在Linux上,您可以运行

ssh -i <private key file> [email protected] "command" 

在服务器上发出“命令”。

编辑

完整的编辑,因为我无法得到以前的答案工作。

$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 
  • 现在使用詹金斯执行一个shell:

powershell -NonInteractive -ExecutionPolicy ByPass /path/to/your/local.ps1

这是我得到了它最终的工作。

+0

这与这个问题有什么关系?你似乎没有在Windows机器上执行远程命令。 –

+0

最终的想法是在远程Windows机器上运行该命令,这可以通过powershell来实现。现在只是想让Jenkins和Powershell开始在Linux上工作。 – 88weighed