【问题标题】:Jenkins execute PowerShell scriptsJenkins 执行 PowerShell 脚本
【发布时间】:2014-07-02 11:20:00
【问题描述】:

我正在尝试从 Jenkins 运行 PowerShell 脚本,但它似乎完全忽略了执行策略!这可以通过直接执行 powershell.exe 或使用 PowerShell plugin

附加信息:

Jenkins 作为 Windows 服务运行(使用本地系统帐户,非交互式)。连接到那个服务器,检查执行策略确实是RemoteSigned:

PS C:\> whoami
nt authority\system

PS C:\> Get-ExecutionPolicy
RemoteSigned
PS C:\>

但是,在运行 Jenkins 构建时,情况并非如此。这是在构建步骤中执行Get-ExecutionPolicy -List 的输出:

d:\workspace\test-job>powershell Get-ExecutionPolicy -list 
  Scope                         ExecutionPolicy
  -----                         ---------------
  MachinePolicy                 Undefined
  UserPolicy                    Undefined
  Process                       Undefined
  CurrentUser                   Undefined
  LocalMachine                  Undefined

我也尝试在构建步骤中明确设置它,没有。

我错过了什么?

【问题讨论】:

    标签: windows powershell jenkins jenkins-plugins executionpolicy


    【解决方案1】:

    拉了两个多小时后,问题是x86/x64!!!

    事实证明,Set-ExecutionPolicy of x64(默认)PowerShell 对 x86 设置没有影响!

    Jenkins 是一个 32 位进程,从 Windows 服务运行 - 它执行 x86 PowerShell!

    此外,x86 PowerShell 的 Modules 目录位于 %systemroot%\SysWow64\WindowsPowerShell\1.0\Modules 下,这是另一个要记住的重要事实!

    【讨论】:

    • 您的回答也让我知道我需要为 x86 进程设置单独的注册表值。
    猜你喜欢
    • 1970-01-01
    • 2019-01-22
    • 1970-01-01
    • 2021-11-06
    • 2012-09-18
    • 2012-06-14
    • 1970-01-01
    • 1970-01-01
    • 2014-01-06
    相关资源
    最近更新 更多