如何解决 Jenkins 代理启动时的一般 'Unexpected error in launching an agent. This is probably a bug in Jenkins' 错误

How to solve generic 'Unexpected error in launching an agent. This is probably a bug in Jenkins' error on Jenkins agent startup

我已经使用以下设置配置了 docker 云动态代理创建: 和代理配置如下:

但他们无法启动。一直在谷歌搜索,但由于我几乎没有什么可以继续处理日志,所以我不知道如何解决这个问题。

Connecting to docker container 2169d7b0f9de955c89916da421dc6e04f41104423d0fdcd28796162225cf491f, running command java -jar //remoting-4.11.2.jar -noReconnect -noKeepAlive -agentLog //agent.log
HTTP/1.1 101 UPGRADED
Content-Type: application/vnd.docker.raw-stream
Connection: Upgrade
Upgrade: tcp
Api-Version: 1.41
Docker-Experimental: false
Ostype: linux
Server: Docker/20.10.12 (linux)
ERROR: Unexpected error in launching an agent. This is probably a bug in Jenkins
Also:   java.lang.Throwable: launched here
    at hudson.slaves.SlaveComputer._connect(SlaveComputer.java:282)
    at hudson.model.Computer.connect(Computer.java:440)
    at hudson.slaves.SlaveComputer.doLaunchSlaveAgent(SlaveComputer.java:796)
    at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)
    at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:393)
    at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:405)
    at org.kohsuke.stapler.interceptor.RequirePOST$Processor.invoke(RequirePOST.java:77)
    at org.kohsuke.stapler.PreInvokeInterceptedFunction.invoke(PreInvokeInterceptedFunction.java:26)
    at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:208)
    at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:141)
    at org.kohsuke.stapler.MetaClass.doDispatch(MetaClass.java:536)
    at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)

最后部分日志停留:

java.io.EOFException: unexpected stream termination
    at hudson.remoting.ChannelBuilder.negotiate(ChannelBuilder.java:464)
    at hudson.remoting.ChannelBuilder.build(ChannelBuilder.java:409)
    at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:432)
    at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:399)
    at io.jenkins.docker.connector.DockerComputerAttachConnector$DockerAttachLauncher.launch(DockerComputerAttachConnector.java:321)
    at hudson.slaves.DelegatingComputerLauncher.launch(DelegatingComputerLauncher.java:63)
    at io.jenkins.docker.connector.DockerDelegatingComputerLauncher.launch(DockerDelegatingComputerLauncher.java:37)
    at hudson.slaves.SlaveComputer.lambda$_connect[=12=](SlaveComputer.java:293)
    at jenkins.util.ContextResettingExecutorService.call(ContextResettingExecutorService.java:46)
    at jenkins.security.ImpersonatingExecutorService.call(ImpersonatingExecutorService.java:80)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

在詹金斯日志中我看到:

96a29780b14e340c1667f2 for node Jenkins JDK11 agent-00000a8utz442 from image: jenkins/agent:alpine
2022-01-27 22:56:32.628+0000 [id=188]   INFO    i.j.d.c.DockerMultiplexedInputStream#readInternal: stderr from Jenkins JDK11 agent-00000a8utz442 (4611c8568d1b73e6a8b7e54613f7ef06c79210f03a96a29780b14e340c1667f2): Jan 27, 2022 10:56:32 PM org.jenkinsci.remoting.engine.WorkDirManager setupLogging
INFO: Using /agent.log as an agent error log destination; output log will not be generated
2022-01-27 22:56:32.628+0000 [id=188]   INFO    i.j.d.c.DockerMultiplexedInputStream#readInternal: stderr from Jenkins JDK11 agent-00000a8utz442 (4611c8568d1b73e6a8b7e54613f7ef06c79210f03a96a29780b14e340c1667f2): Exception in thread "main"
2022-01-27 22:56:32.629+0000 [id=188]   INFO    i.j.d.c.DockerMultiplexedInputStream#readInternal: stderr from Jenkins JDK11 agent-00000a8utz442 (4611c8568d1b73e6a8b7e54613f7ef06c79210f03a96a29780b14e340c1667f2): java.io.FileNotFoundException: /agent.log (Permission denied)
2022-01-27 22:56:32.629+0000 [id=188]   INFO    i.j.d.c.DockerMultiplexedInputStream#readInternal: stderr from Jenkins JDK11 agent-00000a8utz442 (4611c8568d1b73e6a8b7e54613f7ef06c79210f03a96a29780b14e340c1667f2):    at java.base/java.io.FileOutputStream.open0(Native Method)
2022-01-27 22:56:32.629+0000 [id=188]   INFO    i.j.d.c.DockerMultiplexedInputStream#readInternal: stderr from Jenkins JDK11 agent-00000a8utz442 (4611c8568d1b73e6a8b7e54613f7ef06c79210f03a96a29780b14e340c1667f2):    at java.base/java.io.FileOutputStream.open(Unknown Source)
2022-01-27 22:56:32.629+0000 [id=188]   INFO    i.j.d.c.DockerMultiplexedInputStream#readInternal: stderr from Jenkins JDK11 agent-00000a8utz442 (4611c8568d1b73e6a8b7e54613f7ef06c79210f03a96a29780b14e340c1667f2):    at java.base/java.io.FileOutputStream.<init>(Unknown Source)

实际上也没有那么多信息。

在代理配置中,将 /home/jenkins 放在字段远程文件系统根目录中。我遇到了同样的问题,这为我解决了。