jenkins-CICD系列之-Jenkins 打包gitlab的maven 项目

简介: 构建一个简单的springboot的jar包
  1. 进入我之前配置的 jenkins-demo 的配置界面
  2. 选择add post-build step , 选择 Send build artifacts over SSH ,但是我没有 说明我没有配置
  1. 去安装 发送插件

  1. 安装 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)
  1. 原因是下载不下来 ,下载后本地安装 报错 , 原因是没有安装依赖插件 ,这里是分两步下载的


/

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)

  1. 下载完成后 先安装  publish-over.hpi  在安装 publish-over-ssh.hpi 这样都安装成功了
  1. 去全局配置一个远程的 ssh 连接   服务器需要新建 /usr/local/jenkis-demo 不然会提示连不到这个文件夹

  1. 选中  Send build artifacts over SSH  进行如下配置
#!/bin/shpid=$(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

相关文章
|
6天前
|
Java 应用服务中间件 Maven
Maven的三种项目打包方式——pom,jar,war的区别
Maven 提供了多种打包方式,分别适用于不同类型的项目。pom 用于父项目或聚合项目,便于项目的结构和依赖管理;jar 用于Java类库或可执行的Java应用程序;war 则专用于Java Web应用程序的部署。理解这些打包方式的用途和特点,可以帮助开发者更好地配置和管理Maven项目,确保构建和部署过程的顺利进行。无论是单模块项目还是多模块项目,选择合适的打包方式对于项目的成功至关重要。
19 3
|
21天前
|
Java Maven Android开发
【Azure Developer】VS Code打包Java maven Project 遇见 BUILD FAILURE
Unknown lifecycle phase "lean". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>
|
22天前
|
缓存 IDE Java
idea的maven项目打包时没有source下的文件
【10月更文挑战第21天】idea的maven项目打包时没有source下的文件
35 1
|
25天前
|
自然语言处理 jenkins 测试技术
Jenkins适合什么样的项目
【10月更文挑战第18天】Jenkins适合什么样的项目
30 3
|
1月前
|
Java jenkins 持续交付
Centos7下docker的jenkins下载并配置jdk与maven
通过上述步骤,您将成功在CentOS 7上的Docker容器中部署了Jenkins,并配置好了JDK与Maven,为持续集成和自动化构建打下了坚实基础。
99 1
|
1月前
|
Java 测试技术 Maven
maven 打包命令
maven 打包命令
25 6
|
1月前
|
Java Linux Maven
IDEA如何用maven打包(界面和命令两种方式)
【10月更文挑战第14天】本文介绍了两种Maven项目打包方法:命令行与IDEA界面。首先确保已安装Maven并配置环境变量,通过`mvn -v`检查安装。命令行打包需进入项目目录,执行`mvn package`,之后在`target`目录查看结果。IDEA打包则需配置Maven路径,打开Maven Projects窗口,双击Lifecycle下的`package`阶段,同样在`target`目录查找生成文件,并在Build窗口查看日志以排查问题。
663 1
|
1月前
|
Java Shell Maven
Flink-11 Flink Java 3分钟上手 打包Flink 提交任务至服务器执行 JobSubmit Maven打包Ja配置 maven-shade-plugin
Flink-11 Flink Java 3分钟上手 打包Flink 提交任务至服务器执行 JobSubmit Maven打包Ja配置 maven-shade-plugin
103 4
|
1月前
|
Java 应用服务中间件 Maven
SpringBoot Maven 项目打包的艺术--主清单属性缺失与NoClassDefFoundError的优雅解决方案
SpringBoot Maven 项目打包的艺术--主清单属性缺失与NoClassDefFoundError的优雅解决方案
314 0
|
1月前
|
jenkins Java 持续交付
Jenkins打包,发布,部署
Jenkins打包,发布,部署
206 0