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

Jenkins Pipeline长时间运行出现client_loop: send disconnect: Broken pipe报错求助

解决Jenkins Pipeline中client_loop: send disconnect: Broken pipe错误

可能原因及修复方案

  • SSH连接超时:Jenkins Agent与远程服务器的SSH连接因长时间无数据传输被断开
    • 在Pipeline的SSH步骤中添加心跳参数,保持连接活跃:
      sshCommand remote: remote, command: 'your_task_command', sshArgs: '-o ServerAliveInterval=60 -o ServerAliveCountMax=3'
      
    • 也可在Jenkins全局配置(Manage Jenkins > Configure System > SSH remote hosts)中,为目标主机添加上述心跳参数。
  • Agent资源不足:长时间运行的Pipeline占用过多内存,导致连接异常中断
    • 调整Jenkins Agent的JVM内存参数,比如修改启动脚本中的JAVA_OPTS="-Xmx2g"(根据实际情况调整内存值)。
    • 优化Pipeline代码,清理不必要的临时资源、拆分长任务步骤。
  • 远程服务器TCP配置限制:服务器TCP栈设置了较短的空闲连接超时
    • 在远程服务器修改/etc/sysctl.conf,调整TCP保活参数:
      net.ipv4.tcp_keepalive_time=600
      net.ipv4.tcp_keepalive_intvl=60
      net.ipv4.tcp_keepalive_probes=3
      
    • 执行sysctl -p使配置生效。
  • 步骤无持续输出:长耗时命令无输出被判定为空闲连接
    • 给长运行命令添加输出操作,比如your_long_command | tee -a runtime.log,确保有持续输出。
    • 使用timeout命令限制单步骤运行时长,避免无限阻塞。

内容的提问来源于stack exchange,提问作者B. Naga Lakshmi

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.25 17:52:02