Jenkins报错 java.net.UnknownHostException: updates.jenkins.io 等问题的解决
报错一:Failed to install jdk-tool java.net.UnknownHostException: updates.jenkins.io
2023-10-03 14:52:10.515+0000 [id=86] INFO h.m.UpdateCenter$UpdateCenterConfiguration#download: Downloading jdk-tool
2023-10-03 14:52:15.529+0000 [id=86] SEVERE h.model.UpdateCenter$DownloadJob#run: Failed to install jdk-tool
java.net.UnknownHostException: updates.jenkins.io
at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:229)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.base/java.net.Socket.connect(Socket.java:609)
at java.base/sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:305)
at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:177)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:509)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:604)
at java.base/sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:266)
at java.base/sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:373)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:207)
at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1187)
at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1081)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:193)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1592)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1520)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:250)
at hudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:1321)
Caused: java.io.IOException: Failed to load https://updates.jenkins.io/download/plugins/jdk-tool/73.vddf737284550/jdk-tool.hpi to /var/jenkins_home/plugins/jdk-tool.jpi.tmp
at hudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:1332)
Caused: java.io.IOException: Failed to download from https://updates.jenkins.io/download/plugins/jdk-tool/73.vddf737284550/jdk-tool.hpi
at hudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:1366)
at hudson.model.UpdateCenter$DownloadJob._run(UpdateCenter.java:1923)
at hudson.model.UpdateCenter$InstallationJob._run(UpdateCenter.java:2235)
at hudson.model.UpdateCenter$DownloadJob.run(UpdateCenter.java:1897)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at hudson.remoting.AtmostOneThreadExecutor$Worker.run(AtmostOneThreadExecutor.java:121)
at java.base/java.lang.Thread.run(Thread.java:829)
解决方案
如果服务器更改过hostname, 且没有映射到hosts文件时,在hosts文件添加
vim /etc/hosts
添加: 127.0.0.1 `你的hostname`
# 刷新文件生效
nmcli c reload
重启jenkins容器
报错二: The attempt #1 to do the action check updates server failed with an allowed exception:
2023-10-03 14:57:07.526+0000 [id=45] INFO hudson.util.Retrier#start: The attempt #1 to do the action check updates server failed with an allowed exception:
java.net.UnknownHostException: mirrors.tuna.tsinghua.edu.cn
at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:229)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.base/java.net.Socket.connect(Socket.java:609)
at java.base/sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:305)
at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:177)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:509)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:604)
at java.base/sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:266)
at java.base/sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:373)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:207)
at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1187)
at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1081)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:193)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1592)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1520)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:250)
at hudson.model.DownloadService.loadJSON(DownloadService.java:122)
at hudson.model.UpdateSite.updateDirectlyNow(UpdateSite.java:218)
at hudson.model.UpdateSite.updateDirectlyNow(UpdateSite.java:213)
at hudson.PluginManager.checkUpdatesServer(PluginManager.java:2094)
at hudson.util.Retrier.start(Retrier.java:62)
at hudson.PluginManager.doCheckUpdatesServer(PluginManager.java:2065)
at jenkins.DailyCheck.execute(DailyCheck.java:93)
at hudson.model.AsyncPeriodicWork.lambda$doRun$0(AsyncPeriodicWork.java:102)
at java.base/java.lang.Thread.run(Thread.java:829)
2023-10-03 14:57:07.535+0000 [id=45] INFO hudson.util.Retrier#start: Calling the listener of the allowed exception 'mirrors.tuna.tsinghua.edu.cn' at the attempt #1 to do the action check updates server
解决方案
1、关闭防火墙,重启dockers
2、启动jenkins添加dns挂载
sudo systemctl disable firewalld
sudo systemctl stop firewalld
systemctl restart docker
# 关闭并删除Jenkins容器
docker stop jenkins
docker rm -f jenkins
# 启动Jenkins
docker run \
-d -uroot \
-p 9095:8080 \
-p 50000:50000 \
--name jenkins \
-v /data01/jenkins:/var/jenkins_home \
-v /etc/localtime:/etc/localtime \
-v /data01/resolv.conf:/etc/resolv.conf \
--restart unless-stopped \
#添加dns挂载
--dns 8.8.8.8 \
jenkins/jenkins:latest
至此问题解决,希望能帮助到大家!