• Jenkins 添加 Slave Agent 节点时报类文件不匹配错误


    在搭建好的 Jenkins Server 的控制面板上添加 Salve Agent 节点的时候发生了下面的错误

    Checking Java version in the PATH
    openjdk version "1.8.0_345"
    OpenJDK Runtime Environment (build 1.8.0_345-b01)
    OpenJDK 64-Bit Server VM (build 25.345-b01, mixed mode)
    [11/19/22 04:35:32] [SSH] Checking java version of /home/shutang/jenkins/jdk/bin/java
    Couldn't figure out the Java version of /home/shutang/jenkins/jdk/bin/java
    bash: /home/shutang/jenkins/jdk/bin/java: No such file or directory
    
    [11/19/22 04:35:32] [SSH] Checking java version of java
    [11/19/22 04:35:32] [SSH] java -version returned 1.8.0_345.
    [11/19/22 04:35:32] [SSH] Starting sftp client.
    [11/19/22 04:35:33] [SSH] Copying latest remoting.jar...
    Source agent hash is 8D575C4C8219E6AB2039295EC545C6C3. Installed agent hash is 8D575C4C8219E6AB2039295EC545C6C3
    Verified agent jar. No update is necessary.
    Expanded the channel window size to 4MB
    [11/19/22 04:35:33] [SSH] Starting agent process: cd "/home/shutang/jenkins" && java  -jar remoting.jar -workDir /home/shutang/jenkins -jar-cache /home/shutang/jenkins/remoting/jarCache
    Error: A JNI error has occurred, please check your installation and try again
    Exception in thread "main" java.lang.UnsupportedClassVersionError: hudson/remoting/Launcher has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
    	at java.lang.ClassLoader.defineClass1(Native Method)
    	at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
    	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    	at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)
    	at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:351
    	at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:601)
    Agent JVM has terminated. Exit code=1
    [11/19/22 04:35:33] Launch failed - cleaning up connection
    [11/19/22 04:35:33] [SSH] Connection closed.
    Searching for www.datang001.com in /var/jenkins_home/.ssh/known_hosts
    Searching for www.datang001.com:22 in /var/jenkins_home/.ssh/known_hosts
    [11/19/22 04:35:44] [SSH] WARNING: No entry currently exists in the Known Hosts file for this host. Connections will be denied until this new host and its associated key is added to the Known Hosts file.
    Key exchange was not finished, connection is closed.
    SSH Connection failed with IOException: "Key exchange was not finished, connection is closed.", retrying in 15 seconds. There are 3 more retries left.
    Searching for www.datang001.com in /var/jenkins_home/.ssh/known_hosts
    Searching for www.datang001.com:22 in /var/jenkins_home/.ssh/known_hosts
    [11/19/22 04:35:59] [SSH] WARNING: No entry currently exists in the Known Hosts file for this host. Connections will be denied until this new host and its associated key is added to the Known Hosts file.
    Key exchange was not finished, connection is closed.
    SSH Connection failed with IOException: "Key exchange was not finished, connection is closed.", retrying in 15 seconds. There are 2 more retries left.
    Searching for www.datang001.com in /var/jenkins_home/.ssh/known_hosts
    Searching for www.datang001.com:22 in /var/jenkins_home/.ssh/known_hosts
    [11/19/22 04:36:14] [SSH] WARNING: No entry currently exists in the Known Hosts file for this host. Connections will be denied until this new host and its associated key is added to the Known Hosts file.
    Key exchange was not finished, connection is closed.
    SSH Connection failed with IOException: "Key exchange was not finished, connection is closed.", retrying in 15 seconds. There are 1 more retries left.
    Searching for www.datang001.com in /var/jenkins_home/.ssh/known_hosts
    Searching for www.datang001.com:22 in /var/jenkins_home/.ssh/known_hosts
    [11/19/22 04:36:29] [SSH] WARNING: No entry currently exists in the Known Hosts file for this host. Connections will be denied until this new host and its associated key is added to the Known Hosts file.
    Key exchange was not finished, connection is closed.
    ERROR: Connection is not established!
    java.lang.IllegalStateException: Connection is not established!
    	at com.trilead.ssh2.Connection.getRemainingAuthMethods(Connection.java:988)
    	at com.cloudbees.jenkins.plugins.sshcredentials.impl.TrileadSSHPasswordAuthenticator.canAuthenticate(TrileadSSHPasswordAuthenticator.java:83)
    	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:176)
    	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
    	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
    	at java.base/java.util.Spliterators$IteratorSpliterator.tryAdvance(Spliterators.java:1812)
    	at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
    	at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
    	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
    	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    	at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
    	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    	at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
    	at com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator.newInstance(SSHAuthenticator.java:222)
    	at com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator.newInstance(SSHAuthenticator.java:173)
    	at hudson.plugins.sshslaves.SSHLauncher.openConnection(SSHLauncher.java:881)
    	at hudson.plugins.sshslaves.SSHLauncher.lambda$launch$0(SSHLauncher.java:434)
    	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    	at java.base/java.lang.Thread.run(Thread.java:829)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76

    通过查看 Jenkins 官网提供的信息如下

    Beginning with Jenkins 2.357 (released on June 28, 2022) and the forthcoming
    2.361.1 LTS release, Jenkins requires Java 11 or newer. Additionally, beginning
    with Jenkins 2.355 (released on June 14, 2022) and Jenkins 2.346.1 LTS (released
    on June 22, 2022), Jenkins supports Java 17. Plugins have already been prepared
    in JENKINS-68446. Use the Plugin Manager to upgrade all plugins before and after
    upgrading to Jenkins 2.357.
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    可以知道 Slave Agent 上的 JDK1.8 环境版本与 Jenkins Master Server 端的版本不匹配,我部署的 Jenkins Server2.361.2,因此需要 Slave Agent 上提供的应该是 JDK11 或者更新的版本。

  • 相关阅读:
    easyscholar配置秘钥连接Zotero-style,更方便的了解文献!
    再聊Java Stream的一些实战技能与注意点
    C++学习笔记二(堆栈、指针、命名空间、编译步骤)
    谈谈JMM
    一、QT概述
    C++简单上手helloworld 以及 vscode找不到文件的可能性原因
    电力通信专业技术总结,智能电网通信技术总结
    奶茶店冬天怎么提升销量 | 奶茶技术培训
    LogUtils工具类
    最小最大表示法超详细讲解
  • 原文地址:https://blog.csdn.net/weixin_48505120/article/details/127935423