一. 问题
二. 步骤
2.1. 清华源
2.2. Jenkins 配置
2.2.1 config.xml
2.2.2 hudson.model.UpdateCenter.xml
2.2.3 default.json
2.2.4 JDK ...cacerts
2.2.3 Jenkins Reboot
三. 插件
四. 参考
最近升级Jenkins 版本到 2.346.1 后下载插件, 按照网上操作步骤依然不成功; 次哦, 这个插件问题卡壳好久了;
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(Unknown Source)
at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source)
at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
at sun.security.ssl.Handshaker.processLoop(Unknown Source)
at sun.security.ssl.Handshaker.process_record(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at InstallCert.main(InstallCert.java:110)
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(Unknown Source)
at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
at sun.security.validator.Validator.validate(Unknown Source)
at sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
at InstallCert$SavingTrustManager.checkServerTrusted(InstallCert.java:205)
at sun.security.ssl.AbstractTrustManagerWrapper.checkServerTrusted(Unknown Source)
... 9 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
e)
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
at java.security.cert.CertPathBuilder.build(Unknown Source)
... 17 more
然后某天换个思路,瞎折腾一下,然后就好了,特此记录一下,给有需要的人参考;
Dashboard -> Manage Jenkins -> Manage Plugins -> Plugin Manager -> 高级
切换为清华源:
- http://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json
修改如下配置文件:
# C:\ProgramData\Jenkins\.jenkins\config.xml 修改第 17 行, 切换 Jenkins 工作空间目录
F:\Jenkins\workspace\${ITEM_FULL_NAME}
修改如下配置文件:
C:\ProgramData\Jenkins\.jenkins\hudson.model.UpdateCenter.xml
修改后效果如下:
default
http://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json
修改如下配置文件:
C:\ProgramData\Jenkins\.jenkins\updates\default.json
替换如下信息:
1. http://www.google.com -> http://www.baidu.com
2. https://updates.jenkins.io/download -> http://mirrors.tuna.tsinghua.edu.cn/jenkins
注意: 此处是重点;
打开 JDK 路径,比如我的安装路径如下:
C:\Program Files\Java\jdk1.8.0_31
之前一直以为是不是Jenkins 对JDK 要求版本太高了? 后来想着如果还折腾不成功就放弃,直接升级JDK 算了;
# 重点关注
C:\Program Files\Java\jdk1.8.0_31\jre\lib\security
然后我找了下, Android Studio 下的 cacerts 文件:
C:\Program Files\Android\AndroidStudio2021.2\jre\lib\security
次哦,文件大小不一样,算了直接拿这个文件复制到JDK 路径下面:
# 1. 重命名 JDK
C:\Program Files\Java\jdk1.8.0_31\jre\lib\security\cacerts -> C:\Program Files\Java\jdk1.8.0_31\jre\lib\security\cacerts_0
# 2. 复制 Android Studio 中的 cacerts 到 JDK 中
C:\Program Files\Android\AndroidStudio2021.2\jre\lib\security\cacerts -> C:\Program Files\Java\jdk1.8.0_31\jre\lib\security\cacerts
操作好后, 如下图所示:
此时, 修改如下配置:
# Windows 任务管理 -> 服务 启动/关闭/自动重启 方式
C:\Program Files\Jenkins\jenkins.xml
修改后效果为:
jenkins
Jenkins
This service runs Jenkins automation server.
C:\Program Files\Java\jdk1.8.0_31\bin\java.exe
-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -Djavax.net.ssl.trustStore="C:\Program Files\Java\jdk1.8.0_31\jre\lib\security\cacerts" -jar "C:\Program Files\Jenkins\jenkins.war" --httpPort=8083 --webroot="%ProgramData%\Jenkins\war"
rotate
%ProgramData%\Jenkins\jenkins.pid
10000
false
重点参数修改的为:
# 注意: 此处JDK 路径要切换成自己本地机器上实际路径
# -Djavax.net.ssl.trustStore="C:\Program Files\Java\jdk1.8.0_31\jre\lib\security\cacerts"
40 Line -Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -Djavax.net.ssl.trustStore="C:\Program Files\Java\jdk1.8.0_31\jre\lib\security\cacerts" -jar "C:\Program Files\Jenkins\jenkins.war" --httpPort=8083 --webroot="%ProgramData%\Jenkins\war"
# 方式一: 重启 Jenkins
http://localhost:8083/restart
# 方式二【推荐】: 任务管理器 -> 服务 -> Jenkins -> 重新启动
安装如下插件项:
# 持续更新...
...
Blue Ocean
Credentials Binding
Folders
Git
Gradle
Groovy
Metrics Disk Usage
NodeJS
Pipeline
Pipeline: Stage View
PowerShell
Python
Workspace Cleanup
...
1. https://www.jenkins.io/zh/
2. https://mirrors.tuna.tsinghua.edu.cn/jenkins/