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

升级至Agent 4.268后PowerShell运行偶发‘创建管道时出错’问题

偶发Azure DevOps PowerShell任务执行失败问题排查求助

背景

2月中旬将Azure DevOps代理从3.238版本升级至4.268版本,一周后多个管道开始出现PowerShell执行失败问题。涉及环境:

  • Azure DevOps Server版本:2022.2
  • 代理服务器系统:Windows Server 2019、Windows Server 2022
  • 触发任务:PowerShell任务(版本2.232.0)或其他调用PowerShell的任务(如Msbuild)

错误日志示例

========================== Starting Command Output ===========================
##[debug]Entering Invoke-VstsTool.
##[debug] Arguments: '-NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". ''D:\agent\_work\_temp\d342dc0d-9f0b-40c6-9675-a0c695434e78.ps1''"'
##[debug] FileName: ''C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe''
##[debug] WorkingDirectory: ''D:\agent\_work\129\s''
"C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". ''D:\agent\_work\_temp\d342dc0d-9f0b-40c6-9675-a0c695434e78.ps1''"
An error occurred while creating the pipeline.
    + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : RuntimeException
 
##[debug]Exit code: 1
##[debug]Leaving Invoke-VstsTool.
##[error]PowerShell exited with code '1'.
##[debug]Processed: ##vso[task.logissue type=error]PowerShell exited with code '1'.
##[debug]Processed: ##vso[task.complete result=Failed]Error detected
##[debug]Leaving D:\agent\_work\_tasks\PowerShell_e213ff0f-5d5c-4791-802d-52ea3e7be1f1\2.232.0\powershell.ps1.
Finishing: Cleaning managed agent pipeline workspace

问题核心特征

  • 多集合、多服务器/代理均出现故障,出错脚本无明显共性
  • 无法主动复现该错误,系统事件日志、杀毒软件日志未发现相关异常
  • 重装代理无法解决问题;重试任务通常可恢复,但故障频率过高(大型多阶段经典管道每2-3个PowerShell任务就会失败),已无法通过持续重试应对
  • 测试差异:简单Yaml管道连续运行200次未出错,但大型多阶段经典管道故障频发

额外异常情况

Azure DevOps为PowerShell任务自动生成的极简包装脚本也触发了相同错误,脚本内容如下:

$ErrorActionPreference = 'stop'
$ProgressPreference = 'silentlyContinue'
$ErrorView = 'NormalView'
# Write your PowerShell commands here.

Write-Host "Hello World"
if (!(Test-Path -LiteralPath variable:\LASTEXITCODE)) {
    Write-Host '##vso[task.debug]$LASTEXITCODE is not set.'
} else {
    Write-Host ('##vso[task.debug]$LASTEXITCODE: {0}' -f $LASTEXITCODE)
    exit $LASTEXITCODE
}

现寻求该偶发故障的排查思路及解决方案。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.02 00:33:15