今天在虚拟机上安装jenkins,记录一下其中的一个错误的处理。

首先准备好jdk和tomcat,配置好环境

cd /usr/local/apache-tomcat-7.0.57/webapps

执行wget http://mirrors.jenkins-ci.org/war-stable/latest/jenkins.war

webapp下有一个jenkins.war文件

 

之后直接交给tomcat来解压部署

cd ../bin

./startup.sh

 

cd ../logs

tail -100fcatalina.out查看log日志

 

会发现最后后报错:

五月 24, 2018 2:16:55 下午 hudson.model.UpdateCenter updateDefaultSite

警告: Upgrading Jenkins. Failed to update the default Update Site 'default'. Plugin upgrades may fail.

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

         at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)

         at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949)

         at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)

         at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)

         at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1506)

         at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)

         at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)

         at sun.security.ssl.Handshaker.process_record(Handshaker.java:914)

         at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062)

         at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)

         at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)

         at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)

         at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)

         at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)

         at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1512)

         at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1440)

         at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)

         at hudson.model.DownloadService.loadJSON(DownloadService.java:167)

         at hudson.model.UpdateSite.updateDirectlyNow(UpdateSite.java:190)

         at hudson.model.UpdateCenter.updateDefaultSite(UpdateCenter.java:2194)

         at jenkins.install.SetupWizard.init(SetupWizard.java:173)

         at jenkins.install.InstallState$4.initializeState(InstallState.java:110)

         at jenkins.model.Jenkins.setInstallState(Jenkins.java:1033)

         at jenkins.install.InstallUtil.proceedToNextStateFrom(InstallUtil.java:97)

         at jenkins.install.InstallState$1.initializeState(InstallState.java:55)

         at jenkins.model.Jenkins$17.run(Jenkins.java:3149)

         at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169)

         at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)

         at jenkins.model.Jenkins$5.runTask(Jenkins.java:1062)

         at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)

         at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)

         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

         at java.lang.Thread.run(Thread.java:745)

Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

         at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:387)

         at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)

         at sun.security.validator.Validator.validate(Validator.java:260)

         at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:324)

         at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:229)

         at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)

         at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1488)

         ... 29 more

Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

         at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:146)

         at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:131)

         at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)

         at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:382)

         ... 35 more

如果没有看日志,那么打开192.168.211.103:8080/jenkins会显示该jenkins实例似乎已离线

 

为什么会报这个错误呢?

参考:

解决 PKIX:unable to find valid certification path to requested target

原因是就是升级站点的链接https://updates.jenkins.io/update-center.json默认是https的,如何解决呢?

解决方案1:

安装插件那个页面,就是提示你offline的那个页面,不要动。然后打开一个新的tab,输入网址http://192.168.211.103:8080/jenkins/pluginManager/advanced。 这里面最底下有个【升级站点】,把其中的链接由https改成http的就好了,http://updates.jenkins.io/update-center.json。 然后在服务列表中关闭jenkins,再tomcat重新启动,这样就能正常联网了

参考:Jenkenis报错:该jenkins实例似乎已离线

解决方案2:

当然,原则上也可以参考解决PKIX的第二种方式,为updates.jenkins.io生成证书并导入到JAVA_HOME/jre/lib/security目录下(留坑)



Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐