jenkins部署springboot多项目
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/
jenkins部署springboot多项目的更多相关文章
- 使用Jenkins部署Spring Boot项目
jenkins是devops神器,本篇文章介绍如何安装和使用jenkins部署Spring Boot项目 jenkins搭建 部署分为三个步骤: 第一步,jenkins安装 第二步,插件安装和配置 第 ...
- jenkins+windows+springboot+.net项目自动化部署图文教程
之前一直在linux中使用jenkins部署程序,正好现在的项目包括了winfrom程序,所以需要部署到windows系统中 jenkins官网:https://jenkins.io/ 下载之后运行j ...
- 五. jenkins部署springboot项目(2)--windows环境--服务
前提:jenkins和springboot运行在同一台机器 springboot 通过winsw部署为服务 winsw 下载地址:https://github.com/kohsuke/winsw/re ...
- Jenkins部署springboot项目
记录jenkins如何部署springboot项目(jar类型的) 一.首先需要先配置好jenkins的基本配置(jdk.maven--),可在系统管理-->>全局工具配置中进行配置. 配 ...
- 四. jenkins部署springboot项目(1)--window环境
前提:jenkins和springboot运行在同一台机器 springboot项目使用git和maven jenkins所需的插件如Maven,Git等这里就不再详述. 1.jenkins配置git ...
- Jenkins部署git+python项目实现持续集成
目录 1. 创建 item 2. 配置 3. 构建 1. 创建 item 接下来填写创建任务的名字,并选择创建一个 Freestyle project ,点击确认. 2. 配置 接下来进入到项目相关配 ...
- 七. jenkins部署springboot项目(4)-linux环境--远程调试
前提:linux环境,jenkins服务器和springboot服务器不在一台机器. linux环境,jenkins这里就不说了,主要说下和windows环境的不同. 1. jenkins服务器连接s ...
- 六. jenkins部署springboot项目(3)--windows环境--远程windows server服务器
前提:jenkins服务器和windows server服务器不在一台机器上 对于jenkins服务器上编译好的jar或war包如何推送到windows server服务器上. 参照网上的,在wind ...
- 物联网架构成长之路(15)-Jenkins部署SpringBoot
1.前言 现在慢慢也在负责一些工作了.这段时间有空,就多了解了解软件多人开发的一些知识.以前项目都是我一个人做的,从数据库设计到后端再到前端,全部放在一个war包丢到tomcat里面然后运行,利用to ...
随机推荐
- Springboot 拦截器(HandlerInterceptorAdapter)中注入无效
1,传统filter和HandlerInterceptorAdapter的区别 springboot对传统Filter进行增强,添加更多细粒度的操作,分别实现预处理.后处理(调用了Service并返回 ...
- 常用代码c#
当使用 HttpContext.Current用到不是当前线程会出null的情况,可使用 System.Web.HttpRuntime.AppDomainAppPath获取程序的根路 string p ...
- 北京Uber优步司机奖励政策(1月29日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- 北京Uber优步司机奖励政策(1月19日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- 成都Uber优步司机奖励政策(3月29日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- [并发并行]_[线程模型]_[Pthread线程使用模型之一管道Pipeline]
场景 1.经常在Windows, MacOSX 开发C多线程程序的时候, 经常需要和线程打交道, 如果开发人员的数量不多时, 同时掌握Win32和pthread线程 并不是容易的事情, 而且使用Win ...
- day 2 飞机大战原理
1. 程序的图片的坐标 (左上角为顶点) 2.图片变成动态的 3.集成显卡 和独立显卡
- 蓝牙入门知识-CC2541知识
蓝牙是为了能够通信,想要通信就必须遵守一定的规则, Profile 就可以理解为相互约定的规则,因为每个协议栈demo 都会有一个Profile 与之对应, 我们这里的SimpleBLExxx 对应的 ...
- linux 中文输出
#include <stdio.h> #include <stdlib.h> #include <string> #include <fstream> ...
- 获取附加在方法上的Attribute
如下: class Program { static void Main(string[] args) { var methodInfo = typeof(Program).GetMethod(&qu ...