You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GitLab作业用X86 PowerShell致命令失败,需切换至X64版本求助

解决GitLab Runner默认使用x86 PowerShell导致命令执行失败的问题

问题背景

当前GitLab Runner采用shell执行器,配置文件config.toml内容如下:

executor = "shell"
shell = "powershell"

作业中执行$env:PROCESSOR_ARCHITECTURE输出为x86,导致Remove-Website -Name "test"这类依赖x64环境的命令执行失败,报错信息:

Remove-Website : Cannot retrieve the dynamic parameters for the cmdlet. Retrieving the COM class factory for component
with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: 80040154 Class not registered

同一Runner上,该命令在x64 PowerShell中可正常运行,需将GitLab作业默认的x86 PowerShell切换为x64版本。

解决方法

方法1:修改Runner全局配置文件config.toml

Windows系统中,x64 PowerShell的默认路径为C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe,直接在配置文件中指定该完整路径:

executor = "shell"
shell = "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"

(也可使用正斜杠避免转义:C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe)

修改完成后,重启GitLab Runner服务使配置生效:

Restart-Service gitlab-runner

方法2:在CI作业脚本中直接调用x64 PowerShell

若无需修改全局配置,可在单个作业的script中直接指定x64 PowerShell路径执行命令:

deploy_job:
  script:
    # 验证当前架构
    - C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command '$env:PROCESSOR_ARCHITECTURE'
    # 执行目标命令
    - C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command 'Remove-Website -Name "test"'

也可将多个命令打包执行:

deploy_job:
  script:
    - & "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -Command {
        Write-Host "当前架构: $env:PROCESSOR_ARCHITECTURE";
        Remove-Website -Name "test";
      }

方法3:确保GitLab Runner为x64版本

若上述方法无效,检查Runner本身的架构:如果安装的是x86版本的GitLab Runner,即使指定x64 PowerShell也可能存在兼容性问题。需卸载现有x86 Runner,重新下载并安装x64版本的GitLab Runner。

内容的提问来源于stack exchange,提问作者Vishal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 06:11:11