跳过正文
  1. Posts/

Jenkins 升级后 Windows Agent 无法启动的解决方法

·325 字·1 分钟· ·
沈显鹏
作者
沈显鹏
DevOps & Build 工程师 | Python 爱好者 | 开源贡献者
目录

问题描述
#

在将团队的 Jenkins 从 2.235.1 升级到 2.263.3 后,发现 Windows Agent 无法启动,日志报错如下:

[windows-agents] Installing the Jenkins agent service
ERROR: Unexpected error in launching an agent. This is probably a bug in Jenkins
java.lang.NullPointerException
    at hudson.os.windows.ManagedWindowsServiceLauncher.launch(ManagedWindowsServiceLauncher.java:298)

该问题已在 Jenkins Jira 上有反馈:


解决步骤
#

1. 更新 Windows Slaves 插件
#

windows-slaves-plugin 升级到 1.7 版本(支持 Jenkins 2.248+)。

更新后,如果仍出现如下错误:

ERROR: Unexpected error in launching an agent. This is probably a bug in Jenkins
org.jinterop.dcom.common.JIException: Unknown Failure
    at org.jvnet.hudson.wmi.Win32Service$Implementation.start(Win32Service.java:149)

请继续执行下一步。


2. 修改 jenkins-agent.exe.config
#

找到 Jenkins agent 安装目录下的 jenkins-agent.exe.config 文件,注释或删除以下行:

<!-- <supportedRuntime version="v2.0.50727" /> -->

确保配置如下:

<configuration>
  <runtime>
    <generatePublisherEvidence enabled="false"/>
  </runtime>
  <startup>
    <supportedRuntime version="v4.0" />
  </startup>
</configuration>

如果存在 jenkins-slave.exe.config 文件,也需同样修改。


3. 检查 .NET Framework 版本
#

如果启动时提示:

.NET Framework 2.0 or later is required on this computer to run a Jenkins agent as a Windows service

则需要升级本机的 .NET Framework。 可参考:更新 .NET Framework


总结
#

通过 更新插件 + 修改配置文件 + 升级 .NET Framework,即可解决 Jenkins 升级后 Windows Agent 无法启动的问题。

相关文章

Jenkins Linux Agent 配置

·353 字·1 分钟
本文提供了 Jenkins Linux Agent 的逐步配置指南,包括 Java 运行时的准备、节点创建以及常见问题的排查方法。