赞
踩
root@2324d2daa74d:~/jenkins# java -jar agent.jar -jnlpUrl http://192.168.1.18:8080/computer/k8s-node2/jenkins-agent.jnlp -secret d1f55f9ffd189eaaf4b8897b5cf92c263fb2e8724139d42e59ac275284a82643 -workDir "/root/jenkins"
Error: Unable to access jarfile agent.jar
1.复制jenkins页面的agent.jar包下载链接,先下载下来再执行启动命令
root@2324d2daa74d:~/jenkins# wget http://192.168.1.18:8080/jnlpJars/agent.jar
bash: wget: command not found
很有可能出现上面的情况,就是jenkins容器中没有内置wget等命令。
2.通过Jenkins宿主机下载agent.jar包,拷贝至Jenkins容器中,再执行启动命令。
[root@k8s-master ~]# wget http://192.168.1.18:8080/jnlpJars/agent.jar
--2021-11-27 00:45:07-- http://192.168.1.18:8080/jnlpJars/agent.jar
正在连接 192.168.1.18:8080... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1507326 (1.4M) [application/java-archive]
正在保存至: “agent.jar”
100%[===============================================================>] 1,507,326 --.-K/s 用时 0.03s
2021-11-27 00:45:07 (52.6 MB/s) - 已保存 “agent.jar” [1507326/1507326])
[root@k8s-master ~]# docker cp /root/agent.jar jenkins:/root/jenkins //拷贝至Jenkins容器的/root/jenkins目录下
3.在Jenkins容器中查看agent.jar包并执行启动命令
[root@k8s-master ~]# docker exec -it --user root jenkins /bin/bash root@2324d2daa74d:~/jenkins# cd /root/jenkins root@2324d2daa74d:~/jenkins# ls agent.jar root@2324d2daa74d:~/jenkins# java -jar agent.jar -jnlpUrl http://192.168.1.18:8080/computer/k8s-node2/jenkins-agent.jnlp -secret d1f55f9ffd189eaaf4b8897b5cf92c263fb2e8724139d42e59ac275284a82643 -workDir "/root/jenkins" Nov 26, 2021 4:50:25 PM org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDir INFO: Using /root/jenkins/remoting as a remoting work directory Nov 26, 2021 4:50:25 PM org.jenkinsci.remoting.engine.WorkDirManager setupLogging INFO: Both error and output logs will be printed to /root/jenkins/remoting Nov 26, 2021 4:50:25 PM hudson.remoting.jnlp.Main createEngine INFO: Setting up agent: k8s-node2 Nov 26, 2021 4:50:25 PM hudson.remoting.jnlp.Main$CuiListener <init> INFO: Jenkins agent is running in headless mode. Nov 26, 2021 4:50:25 PM hudson.remoting.Engine startEngine INFO: Using Remoting version: 4.10 Nov 26, 2021 4:50:25 PM org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDir INFO: Using /root/jenkins/remoting as a remoting work directory Nov 26, 2021 4:50:25 PM hudson.remoting.jnlp.Main$CuiListener status INFO: Locating server among [http://192.168.1.18:8080/] Nov 26, 2021 4:50:25 PM org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver resolve INFO: Remoting server accepts the following protocols: [JNLP4-connect, Ping] Nov 26, 2021 4:50:25 PM hudson.remoting.jnlp.Main$CuiListener status INFO: Agent discovery successful Agent address: 192.168.1.18 Agent port: 50000 Identity: f0:e1:b2:8d:35:66:e5:34:1e:7f:4b:9c:0c:06:a1:f0 Nov 26, 2021 4:50:25 PM hudson.remoting.jnlp.Main$CuiListener status INFO: Handshaking Nov 26, 2021 4:50:25 PM hudson.remoting.jnlp.Main$CuiListener status INFO: Connecting to 192.168.1.18:50000 Nov 26, 2021 4:50:25 PM hudson.remoting.jnlp.Main$CuiListener status INFO: Trying protocol: JNLP4-connect Nov 26, 2021 4:50:25 PM org.jenkinsci.remoting.protocol.impl.BIONetworkLayer$Reader run INFO: Waiting for ProtocolStack to start. Nov 26, 2021 4:50:25 PM hudson.remoting.jnlp.Main$CuiListener status INFO: Remote identity confirmed: f0:e1:b2:8d:35:66:e5:34:1e:7f:4b:9c:0c:06:a1:f0 Nov 26, 2021 4:50:26 PM hudson.remoting.jnlp.Main$CuiListener status INFO: Connected //连接成功
----->在执行jenkins节点启动命令时,应该换成nohup 启动命令 &
的方式,这样可以让它后台运行,不至于占用终端。
现在Jenkins的node节点已经成功添加了!
最近刚申请了个微信公众号,上面也会分享一些运维知识,大家点点发财手关注一波,感谢大家。 【原创公众号】:非著名运维 【福利】:公众号回复 “资料” 送运维自学资料大礼包哦!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。