Linux搭建Jenkins持续集成并给出连接gogs仓库对springboot工程自动部署的所需内容
Linux安装Jenkins:https://www.cnblogs.com/wintest/p/12182067.html
Jenkins可选插件为空怎么办?
https://www.cnblogs.com/hellxz/p/jenkins_install_plugins_faster.html
如果在插件列表找不到插件或者安装插件失败,可以选择手动下载插件并在高级页进行上传。
这里maven-plugin.hpi文件就是下载手动上传安装的。
http://updates.jenkins-ci.org/download/plugins/maven-plugin/2.14/maven-plugin.hpi
Linux安装配置Maven:https://blog.csdn.net/zjh_746140129/article/details/79017448
Linux安装Git:https://www.cnblogs.com/fuzongle/p/12830572.html
Jenkins配置Git账号密码:https://www.cnblogs.com/zhuochong/p/10082566.html
Linux配置springboot工程:
https://blog.csdn.net/weixin_33795743/article/details/92072917
https://blog.csdn.net/m0_46698142/article/details/114023935
Jenkins构建成功后钉钉通知消息:
https://www.cnblogs.com/fanpl/articles/12875989.html
https://www.cnblogs.com/forlive/p/12469266.html
https://www.cnblogs.com/wangxu01/articles/11149851.html
https://blog.csdn.net/ljj123_/article/details/105173171
Dingding[钉钉]Plugin插件手动下载安装,下载地址:http://updates.jenkins-ci.org/download/plugins/dingding-notifications/
192.168.1.229
3,jenkins的shell脚本用docker打镜像,并且调用启动脚本
4,启动脚本:docker镜像的jar包启动
Docker将jar包制作为镜像,在Docker环境运行_路大师_XA的博客-CSDN博客_jar包制作docker镜像
docker删除容器_Hello东西南北的博客-CSDN博客_docker 删除容器
5,进入容器
进入容器的命令
docker exec -it c0d2f47fdf95 /bin/sh # 进入容器(容器id)
在指定位置文件夹列表的每个文件夹里面都要创建一个Dockerfile文件,API网关的Dockerfile文件示例
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ADD digitaltwins-api-0.0.1-SNAPSHOT.jar digitaltwins-api-0.0.1-SNAPSHOT.jar
ENTRYPOINT ["java","-jar","/digitaltwins-api-0.0.1-SNAPSHOT.jar","--spring.profiles.active=qa"]
API网关的shell脚本和Dockerfile文件
#! /bin/bash
# jenkins编译后的target目录
originalDir=/root/.jenkins/workspace/DigitalTwinsPlatform
# api网关 jar地址
apiProject=${originalDir}/digitaltwins-api/target/digitaltwins-api-0.0.1-SNAPSHOT.jar
# 拷贝jar包到指定位置
cp $apiProject /opt/module/digital_twins_platform_jars/ApiProject/
# (如果有)停掉api网关的容器并删除
for i in `docker ps | grep apiproject|awk '{print $1}'`
do
docker stop $i
done
for i in `docker ps -a | grep apiproject|awk '{print $1}'`
do
docker rm -f $i
done
# (如果有)删除api网关的镜像
for i in `docker images|grep apiproject|awk '{print $1}'`
do
docker rmi $i
done
# 构建镜像
cd /opt/module/digital_twins_platform_jars/ApiProject/
docker build -t digital-twins/spring-boot-docker-apiproject:latest .
#运行镜像,生成容器实例
docker run -d --name spring-boot-docker-apiproject001 --network=host -p 8082:8082 digital-twins/spring-boot-docker-apiproject
ConfigServer的shell脚本和Dockerfile文件
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ADD digitaltwins-config-center-server-0.0.1-SNAPSHOT.jar digitaltwins-config-center-server-0.0.1-SNAPSHOT.jar
ENTRYPOINT ["java","-jar","/digitaltwins-config-center-server-0.0.1-SNAPSHOT.jar","--spring.profiles.active=qa"]
#! /bin/bash
# jenkins编译后的target目录
originalDir=/root/.jenkins/workspace/DigitalTwinsPlatform-ConfigServer
# jar地址
apiProject=${originalDir}/digitaltwins-config-center/digitaltwins-config-center-server/target/digitaltwins-config-center-server-0.0.1-SNAPSHOT.jar
# 拷贝jar包到指定位置
cp $apiProject /opt/module/digital_twins_platform_jars/ConfigServerProject/
# (如果有)停掉api网关的容器并删除
for i in `docker ps | grep configserver|awk '{print $1}'`
do
docker stop $i
done
for i in `docker ps -a | grep configserver|awk '{print $1}'`
do
docker rm -f $i
done
# (如果有)删除api网关的镜像
for i in `docker images|grep configserver|awk '{print $1}'`
do
docker rmi $i
done
# 构建镜像
cd /opt/module/digital_twins_platform_jars/ConfigServerProject/
docker build -t digital-twins/spring-boot-docker-configserver:latest .
#运行镜像,生成容器实例
docker run -d --name spring-boot-docker-configserver001 --network=host -p 8081:8081 digital-twins/spring-boot-docker-configserver
DigitalCenterServer的shell脚本和Dockerfile文件
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ADD digitaltwins-digital-center-server-0.0.1-SNAPSHOT.jar digitaltwins-digital-center-server-0.0.1-SNAPSHOT.jar
ENTRYPOINT ["java","-jar","/digitaltwins-digital-center-server-0.0.1-SNAPSHOT.jar","--spring.profiles.active=qa"]
#! /bin/bash
# jenkins编译后的target目录
originalDir=/root/.jenkins/workspace/DigitalTwinsPlatform-DigitalCenterServer
# jar地址
apiProject=${originalDir}/digitaltwins-digital-center/digitaltwins-digital-center-server/target/digitaltwins-digital-center-server-0.0.1-SNAPSHOT.jar
# 拷贝jar包到指定位置
cp $apiProject /opt/module/digital_twins_platform_jars/DigitalCenterProject/
# (如果有)停掉api网关的容器并删除
for i in `docker ps | grep digitalcenterserver|awk '{print $1}'`
do
docker stop $i
done
for i in `docker ps -a | grep digitalcenterserver|awk '{print $1}'`
do
docker rm -f $i
done
# (如果有)删除api网关的镜像
for i in `docker images|grep digitalcenterserver|awk '{print $1}'`
do
docker rmi $i
done
# 构建镜像
cd /opt/module/digital_twins_platform_jars/DigitalCenterProject/
docker build -t digital-twins/spring-boot-docker-digitalcenterserver:latest .
#运行镜像,生成容器实例
docker run -d --name spring-boot-docker-digitalcenterserver001 --network=host -p 8084:8084 digital-twins/spring-boot-docker-digitalcenterserver
ModelServer的shell脚本和Dockerfile文件
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ADD digitaltwins-model-server-1.0.0-SNAPSHOT.jar digitaltwins-model-server-1.0.0-SNAPSHOT.jar
ENTRYPOINT ["java","-jar","/digitaltwins-model-server-1.0.0-SNAPSHOT.jar","--spring.profiles.active=qa"]
#! /bin/bash
# jenkins编译后的target目录
originalDir=/root/.jenkins/workspace/DigitalTwinsPlatform-ModelServer
# jar地址
apiProject=${originalDir}/digitaltwins-model/digitaltwins-model-server/target/digitaltwins-model-server-1.0.0-SNAPSHOT.jar
# 拷贝jar包到指定位置
cp $apiProject /opt/module/digital_twins_platform_jars/ModelServerProject/
# (如果有)停掉api网关的容器并删除
for i in `docker ps | grep modelserver|awk '{print $1}'`
do
docker stop $i
done
for i in `docker ps -a | grep modelserver|awk '{print $1}'`
do
docker rm -f $i
done
# (如果有)删除api网关的镜像
for i in `docker images|grep modelserver|awk '{print $1}'`
do
docker rmi $i
done
# 构建镜像
cd /opt/module/digital_twins_platform_jars/ModelServerProject/
docker build -t digital-twins/spring-boot-docker-modelserver:latest .
#运行镜像,生成容器实例
docker run -d --name spring-boot-docker-modelserver001 --network=host -p 8091:8091 digital-twins/spring-boot-docker-modelserver
MqCenter的shell脚本和Dockerfile文件
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ADD digitaltwins-mq-center-server-0.0.1-SNAPSHOT.jar digitaltwins-mq-center-server-0.0.1-SNAPSHOT.jar
ENTRYPOINT ["java","-jar","/digitaltwins-mq-center-server-0.0.1-SNAPSHOT.jar","--spring.profiles.active=qa"]
#! /bin/bash
# jenkins编译后的target目录
originalDir=/root/.jenkins/workspace/DigitalTwinsPlatform-MqCenter
# jar地址
apiProject=${originalDir}/digitaltwins-mq-center/digitaltwins-mq-center-server/target/digitaltwins-mq-center-server-0.0.1-SNAPSHOT.jar
# 拷贝jar包到指定位置
cp $apiProject /opt/module/digital_twins_platform_jars/MqCenterProject/
# (如果有)停掉api网关的容器并删除
for i in `docker ps | grep mqcenter|awk '{print $1}'`
do
docker stop $i
done
for i in `docker ps -a | grep mqcenter|awk '{print $1}'`
do
docker rm -f $i
done
# (如果有)删除api网关的镜像
for i in `docker images|grep mqcenter|awk '{print $1}'`
do
docker rmi $i
done
# 构建镜像
cd /opt/module/digital_twins_platform_jars/MqCenterProject/
docker build -t digital-twins/spring-boot-docker-mqcenter:latest .
#运行镜像,生成容器实例
docker run -d --name spring-boot-docker-mqcenter001 --network=host -p 8083:8083 digital-twins/spring-boot-docker-mqcenter
AppDemo的shell脚本和Dockerfile文件
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ADD digitaltwins-appdemo-0.0.1-SNAPSHOT.jar digitaltwins-appdemo-0.0.1-SNAPSHOT.jar
ENTRYPOINT ["java","-jar","/digitaltwins-appdemo-0.0.1-SNAPSHOT.jar","--spring.profiles.active=qa"]
#! /bin/bash
# jenkins编译后的target目录
originalDir=/root/.jenkins/workspace/DigitalTwinsPlatform-AppDemo
# jar地址
apiProject=${originalDir}/digitaltwins-appdemo/target/digitaltwins-appdemo-0.0.1-SNAPSHOT.jar
# 拷贝jar包到指定位置
cp $apiProject /opt/module/digital_twins_platform_jars/AppdemoProject/
# (如果有)停掉api网关的容器并删除
for i in `docker ps | grep appdemo|awk '{print $1}'`
do
docker stop $i
done
for i in `docker ps -a | grep appdemo|awk '{print $1}'`
do
docker rm -f $i
done
# (如果有)删除api网关的镜像
for i in `docker images|grep appdemo|awk '{print $1}'`
do
docker rmi $i
done
# 构建镜像
cd /opt/module/digital_twins_platform_jars/AppdemoProject/
docker build -t digital-twins/spring-boot-docker-appdemo:latest .
#运行镜像,生成容器实例
docker run -d --name spring-boot-docker-appdemo001 --network=host -p 8070:8070 digital-twins/spring-boot-docker-appdemo
-------------------------------------------
个性签名:独学而无友,则孤陋而寡闻。做一个灵魂有趣的人!
如果觉得这篇文章对你有小小的帮助的话,记得在右下角点个“推荐”哦,博主在此感谢!
万水千山总是情,打赏一分行不行,所以如果你心情还比较高兴,也是可以扫码打赏博主,哈哈哈(っ•̀ω•́)っ✎⁾⁾!