【问题标题】:Setup Jenkins running on Linux to execute PowerShell script设置在 Linux 上运行的 Jenkins 以执行 PowerShell 脚本
【发布时间】:2016-09-15 10:51:49
【问题描述】:

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

Linux 上的主 Jenkins / Windows 上的奴隶。这行得通吗?

【问题讨论】:

    标签: powershell jenkins jenkins-plugins windows-server-2008


    【解决方案1】:

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

    ssh -i <private key file> user@host "command"
    

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

    【讨论】:

      【解决方案2】:

      编辑

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

      $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
      
      • 现在使用 Jenkins 执行 shell:

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

      这就是我最终得到它的方式。

      【讨论】:

      • 这与问题有什么关系?您似乎没有在 Windows 机器上执行远程命令。
      • 最终的想法是在远程 Windows 机器上运行命令,这可以通过 powershell 实现。现在只是想让 Jenkins 和 Powershell 在 Linux 上工作。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-06
      • 2021-03-14
      • 1970-01-01
      • 2019-01-22
      相关资源
      最近更新 更多