jenkins部署springboot多项目
2024-08-24 19:10:30
war包的部署问题不大,这里记录jar包的部署过程:
1:jar包的体积过大问题
pom.xml参考以下配置(依赖包会分离到target/lib/,jar包体积由几十M缩小到几k)
<build>
<plugins> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.ylcloud.admin.AdminWebApplication</mainClass>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin> </plugins>
</build>
2:
对各个项目的分离出来的lib要做一下整合,然后上传到服务器启动类的根目录(要注意的是一般项目架构定了之后lib包基本是没什么改动的,只有个别模块的依赖包会持续更新,后续在jenkins的post step传上去就可以了)
3:
结合shell进行自动部署,主要是3个脚本,这里只做一下工作记录:
第一个是进程结束脚本:
#!/bin/bash
echo "Stopping SpringBoot Application for CMP"
#ls
pid=`ps -ef | grep $* | grep -v grep | awk '{print $2}'`
if [ -n "$pid" ]
then kill - $pid
else echo "no pid"
fi echo "run end"
第二个是项目监控脚本(保证项目按顺序执行)
#!/bin/bash
echo "start script ................" file=$ while [ -f $file ]
do
echo "find log ........."
result=`grep "启动成功" $file`
if [[ "$result" != "" ]]
then
echo "springboot start ........."
break
else
echo "running ......."
sleep 1s
fi
done
echo "springboot Started..........."
第三个是项目启动脚本:
#!/bin/bash
source /etc/profile jarversion='-0.0.1-SNAPSHOT.jar'
basepath='/cjh/yl_cloud/' runjar(){ sh test.sh $ nohup java -jar $ $$jarversion > $basepath$ & >& & sh tt.sh $basepath$ echo $ } runjar 'ylcloud-customer-service' 'nohup.out' '核心模块启动完成' '-Xms10m -Xmx500m' echo '项目启动成功'
转载请注明博客出处:http://www.cnblogs.com/cjh-notes/
最新文章
- 纯C#实现屏幕指定区域截屏
- goim 及时消息 集成
- iscroll修改
- Activiti 查看流程图
- Linux下Hadoop的简单安装
- 【CodeForces】【148D】Bag of mice
- mk文件剖析
- 用crontab、crond在嵌入式系统中添加定时任务
- 无限循环的ViewPager
- leetcode Contains Duplicate python
- 变化Android系统属性SystemProperties.set(&;quot;sys.powerctl&;quot;, &;quot;shutdown&;quot;)关机分析
- CubieBoard开发板数据源介绍
- 说说Java代理模式
- C语言pow()函数的计算精度问题
- MobileForm控件的使用方式-用.NET(C#)开发APP的学习日志
- js监听用户思否在当前页面
- LVS详细介绍以及遇到的坑
- 洛谷3703 [SDOI2017] 树点染色 【LCT】【线段树】
- mySQL 判断表是否存
- JavaWeb开发之详解Servlet及Servlet容器