- 进入我之前配置的 jenkins-demo 的配置界面
- 选择add post-build step , 选择 Send build artifacts over SSH ,但是我没有 说明我没有配置
- 去安装 发送插件
- 安装 publish-over-ssh 这个插件 , 发现抱错 , 是这个下载不下来 。复制连接先下载 https://updates.jenkins.io/download/plugins/publish-over/0.22/publish-over.hpi
java.security.cert.CertificateNotYetValidException: NotBefore: WedOct1212:50:06CST2022atjava.base/sun.security.x509.CertificateValidity.valid(CertificateValidity.java:273) atjava.base/sun.security.x509.X509CertImpl.checkValidity(X509CertImpl.java:619) atjava.base/sun.security.provider.certpath.BasicChecker.verifyValidity(BasicChecker.java:190) atjava.base/sun.security.provider.certpath.BasicChecker.check(BasicChecker.java:144) atjava.base/sun.security.provider.certpath.PKIXMasterCertPathValidator.validate(PKIXMasterCertPathValidator.java:125) Caused: java.security.cert.CertPathValidatorException: validitycheckfailedatjava.base/sun.security.provider.certpath.PKIXMasterCertPathValidator.validate(PKIXMasterCertPathValidator.java:135) atjava.base/sun.security.provider.certpath.PKIXCertPathValidator.validate(PKIXCertPathValidator.java:224) atjava.base/sun.security.provider.certpath.PKIXCertPathValidator.validate(PKIXCertPathValidator.java:144) atjava.base/sun.security.provider.certpath.PKIXCertPathValidator.engineValidate(PKIXCertPathValidator.java:83) atjava.base/java.security.cert.CertPathValidator.validate(CertPathValidator.java:309) atjava.base/sun.security.validator.PKIXValidator.doValidate(PKIXValidator.java:364) Caused: sun.security.validator.ValidatorException: PKIXpathvalidationfailedatjava.base/sun.security.validator.PKIXValidator.doValidate(PKIXValidator.java:369) atjava.base/sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:263) atjava.base/sun.security.validator.Validator.validate(Validator.java:264) atjava.base/sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:231) atjava.base/sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:132) atjava.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.checkServerCerts(CertificateMessage.java:1341) Caused: javax.net.ssl.SSLHandshakeException: PKIXpathvalidationfailed: java.security.cert.CertPathValidatorException: validitycheckfailedatjava.base/sun.security.ssl.Alert.createSSLException(Alert.java:131) atjava.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:371) atjava.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:314) atjava.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:309) atjava.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.checkServerCerts(CertificateMessage.java:1357) atjava.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.onConsumeCertificate(CertificateMessage.java:1232) atjava.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.consume(CertificateMessage.java:1175) atjava.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:396) atjava.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:480) atjava.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:458) atjava.base/sun.security.ssl.TransportContext.dispatch(TransportContext.java:201) atjava.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:172) atjava.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1500) atjava.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1415) atjava.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:450) atjava.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:421) atjava.base/sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:580) atjava.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:183) atjava.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1665) atjava.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1589) atjava.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:224) athudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:1291) Caused: java.io.IOException: Failedtoloadhttps://updates.jenkins.io/download/plugins/publish-over-ssh/1.24/publish-over-ssh.hpi to /var/lib/jenkins/plugins/publish-over-ssh.jpi.tmpathudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:1302) Caused: java.io.IOException: Failedtodownloadfromhttps://updates.jenkins.io/download/plugins/publish-over-ssh/1.24/publish-over-ssh.hpiathudson.model.UpdateCenter$UpdateCenterConfiguration.download(UpdateCenter.java:1336) athudson.model.UpdateCenter$DownloadJob._run(UpdateCenter.java:1893) athudson.model.UpdateCenter$InstallationJob._run(UpdateCenter.java:2205) athudson.model.UpdateCenter$DownloadJob.run(UpdateCenter.java:1867) atjava.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) atjava.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) athudson.remoting.AtmostOneThreadExecutor$Worker.run(AtmostOneThreadExecutor.java:121) atjava.base/java.lang.Thread.run(Thread.java:833)
- 原因是下载不下来 ,下载后本地安装 报错 , 原因是没有安装依赖插件 ,这里是分两步下载的
/
java.io.IOException: Failedtoload: PublishOverSSH (publish-over-ssh1.24) -publish-over的版本0.22丢失。安装版本0.22或者更高的可以修复。athudson.PluginWrapper.resolvePluginDependencies(PluginWrapper.java:1018) athudson.PluginManager.dynamicLoad(PluginManager.java:926) Caused: java.io.IOException: Failedtoinstallpublish-over-sshpluginathudson.PluginManager.dynamicLoad(PluginManager.java:940) athudson.model.UpdateCenter$InstallationJob._run(UpdateCenter.java:2217) Caused: java.io.IOException: Failedtodynamicallydeploythispluginathudson.model.UpdateCenter$InstallationJob._run(UpdateCenter.java:2221) athudson.model.UpdateCenter$DownloadJob.run(UpdateCenter.java:1867) atjava.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) atjava.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) athudson.remoting.AtmostOneThreadExecutor$Worker.run(AtmostOneThreadExecutor.java:121) atjava.base/java.lang.Thread.run(Thread.java:833)
- 下载完成后 先安装 publish-over.hpi 在安装 publish-over-ssh.hpi 这样都安装成功了
- 去全局配置一个远程的 ssh 连接 服务器需要新建 /usr/local/jenkis-demo 不然会提示连不到这个文件夹
- 选中 Send build artifacts over SSH 进行如下配置
pid=$(cat /usr/local/jenkis-demo/UploadSchedule.pid)echo$pid# 判断示范存在这个pidpid_exist=$(ps aux | awk '{print $2}'| grep -w $pid)echo$pid_exist# 如果不存在,pid是空的 -n 代表检查字符串长度是否为0 是就返回trueif [ -n"$pid_exist" ] thenecho"have pid kill"#删除 UploadSchedule.pid 这个文件中的pidkill-9$(cat /usr/local/jenkis-demo/UploadSchedule.pid)fi# 启动java 并且将pid写到 UploadSchedule.pid 文件中nohup /usr/local/jdk-17.0.3.1/bin/java -jar /usr/local/jenkis-demo/target/jenkins-demo.jar > /usr/local/jenkis-demo/log/jenkis-demo.log 2>&1 & echo$! > /usr/local/jenkis-demo/UploadSchedule.pid