ludu-cloud/.drone.yml

179 lines
6.0 KiB
YAML
Raw Normal View History

2024-08-12 17:58:26 +08:00
kind: pipeline # 定义对象类型还有secret和signature两种类型
type: docker # 定义流水线类型还有kubernetes、exec、ssh等类型
name: ludu-system-drone # 定义流水线名称
2024-08-22 11:33:52 +08:00
environment:
module: ${module}
2024-08-12 17:58:26 +08:00
steps: # 定义流水线执行步骤,这些步骤将顺序执行
- name: package # 流水线名称
image: maven:3-jdk-8 # 定义创建容器的Docker镜像
volumes: # 将容器内目录挂载到宿主机仓库需要开启Trusted设置
- name: maven-cache
path: /root/.m2 # 将maven下载依赖的目录挂载出来防止重复下载
- name: maven-build
path: /app/build # 将应用打包好的Jar和执行脚本挂载出来
commands: # 定义在Docker容器中执行的shell命令
2024-08-22 11:47:11 +08:00
# - mvn package -Dmaven.test.skip=true # 应用打包命令
2024-08-12 17:58:26 +08:00
2024-08-22 11:33:52 +08:00
- |
if echo "$module" | grep -q "gateway" || echo "$module" | grep -q "all"; then
echo "gateway start copy to volumes..."
fi
if echo "$module" | grep -q "system" || echo "$module" | grep -q "all"; then
2024-08-22 11:36:31 +08:00
echo "system start copy to volumes..."
2024-08-22 11:33:52 +08:00
fi
if echo "$module" | grep -q "infra" || echo "$module" | grep -q "all"; then
2024-08-22 11:36:31 +08:00
echo "infra start copy to volumes..."
2024-08-22 11:33:52 +08:00
fi
if echo "$module" | grep -q "job" || echo "$module" | grep -q "all"; then
2024-08-22 11:36:31 +08:00
echo "job start copy to volumes..."
2024-08-22 11:33:52 +08:00
fi
if echo "$module" | grep -q "ticketing" || echo "$module" | grep -q "all"; then
2024-08-22 11:36:31 +08:00
echo "ticketing start copy to volumes..."
2024-08-22 11:33:52 +08:00
fi
if echo "$module" | grep -q "parking" || echo "$module" | grep -q "all"; then
2024-08-22 11:36:31 +08:00
echo "parking start copy to volumes..."
2024-08-22 11:33:52 +08:00
fi
if echo "$module" | grep -q "datacenter" || echo "$module" | grep -q "all"; then
2024-08-22 11:36:31 +08:00
echo "datacenter start copy to volumes..."
2024-08-22 11:33:52 +08:00
fi
2024-08-22 11:51:35 +08:00
- echo "Finished checks for module"
2024-08-22 11:50:16 +08:00
2024-08-22 11:33:52 +08:00
# - name: copy-to-object # 构建基础模块和复制票务停车场到轮渡服务器
#
# image: appleboy/drone-ssh # SSH工具镜像
#
# settings:
#
# host: 101.43.112.107 # 远程连接地址
#
# username: root # 远程连接账号
#
# password:
#
# from_secret: ssh_password # 从Secret中读取SSH密码
#
# port: 22 # 远程连接端口
#
# command_timeout: 15m # 远程执行命令超时时间
#
# script:
#
# - echo "start copy"
2024-08-22 10:15:44 +08:00
# - cd /ludu/maven
# - tar -cf ludu-build.tar ./build
# - scp ludu-build.tar root@121.36.203.133:/ludu/maven
2024-08-22 09:50:02 +08:00
# - scp -r /ludu/maven/build/yudao-gateway root@121.36.203.133:/ludu/maven/build
# - echo "gateway done"
# - scp -r /ludu/maven/build/yudao-module-system root@121.36.203.133:/ludu/maven/build
# - echo "system done"
# - scp -r /ludu/maven/build/ludu-module-ticketing root@121.36.203.133:/ludu/maven/build
# - echo "ticketing done"
# - scp -r /ludu/maven/build/ludu-module-parking root@121.36.203.133:/ludu/maven/build
# - echo "parking done"
# - scp -r /ludu/maven/build/yudao-module-infra root@121.36.203.133:/ludu/maven/build
# - echo "infra done"
# - scp -r /ludu/maven/build/ludu-job-admin root@121.36.203.133:/ludu/maven/build
# - echo "job done"
2024-08-22 11:33:52 +08:00
# - scp -r /ludu/maven/build/ludu-module-datacenter root@120.46.37.243:/ludu/maven/build
# - echo "datacenter done"
2024-08-22 10:15:44 +08:00
2024-08-22 11:33:52 +08:00
# - name: build-other-service
#
# image: appleboy/drone-ssh # SSH工具镜像
#
# settings:
#
# host: 120.46.37.243 # 远程连接地址
#
# username: root # 远程连接账号
#
# password:
#
# from_secret: ssh_password2 # 从Secret中读取SSH密码
#
# port: 22 # 远程连接端口
#
# command_timeout: 5m # 远程执行命令超时时间
#
# script:
#
# - cd /ludu/maven/build/ludu-module-datacenter/
# - chmod +x ./run.sh # 更改为可执行脚本
# - ./run.sh || echo "ludu-module-datacenter build failed" # 运行脚本打包应用镜像并运行
2024-08-22 10:15:44 +08:00
# - name: object-build
#
# image: appleboy/drone-ssh # SSH工具镜像
#
# settings:
#
# host: 121.36.203.133 # 远程连接地址
#
# username: root # 远程连接账号
#
# password:
#
# from_secret: ssh_password3 # 从Secret中读取SSH密码
#
# port: 22 # 远程连接端口
#
# command_timeout: 20m # 远程执行命令超时时间
#
# script:
# - cd /ludu/maven
# - rm -rf ./build
# - tar -xf ludu-build.tar -C ./
#
# - cd /ludu/maven/build/yudao-gateway/
# - chmod +x ./run.sh # 更改为可执行脚本
# - ./run.sh || echo "ludu-module-ticketing build failed" # 运行脚本打包应用镜像并运行
#
# - cd /ludu/maven/build/yudao-module-system/
# - chmod +x ./run.sh # 更改为可执行脚本
# - ./run.sh || echo "ludu-module-datacenter build failed" # 运行脚本打包应用镜像并运行
#
# - cd /ludu/maven/build/ludu-module-ticketing/
# - chmod +x ./run.sh # 更改为可执行脚本
# - ./run.sh || echo "ludu-module-ticketing build failed" # 运行脚本打包应用镜像并运行
#
# - cd /ludu/maven/build/ludu-module-parking/
# - chmod +x ./run.sh # 更改为可执行脚本
# - ./run.sh || echo "ludu-module-parking build failed" # 运行脚本打包应用镜像并运行
#
# - cd /ludu/maven/build/yudao-module-infra/
# - chmod +x ./run.sh # 更改为可执行脚本
# - ./run.sh || echo "yudao-module-infra build failed" # 运行脚本打包应用镜像并运行
#
# - cd /ludu/maven/build/ludu-job-admin/
# - chmod +x ./run.sh # 更改为可执行脚本
# - ./run.sh || echo "ludu-job-admin build failed" # 运行脚本打包应用镜像并运行
2024-08-21 16:28:56 +08:00
2024-08-12 17:58:26 +08:00
volumes: # 定义流水线挂载目录,用于共享数据
- name: maven-build
host:
path: /ludu/maven/build # 从宿主机中挂载的目录
- name: maven-cache
host:
path: /ludu/maven/cache # 从宿主机中挂载的目录