ci(drone): 优化 Drone构建流程

- 重构构建步骤,提高流程清晰度
- 添加文件存在性检查和错误处理,增强构建鲁棒性
- 优化目录结构创建方式
- 更新 Docker 镜像构建步骤
- 调整 Docker Compose 文件处理方式
- 移除未使用的触发配置
This commit is contained in:
lujianxin 2025-06-24 18:10:14 +08:00
parent a8c3996cfa
commit fb6853f57c
1 changed files with 17 additions and 16 deletions

View File

@ -12,21 +12,26 @@ steps:
- name: build-output - name: build-output
path: /home/app/build path: /home/app/build
commands: commands:
- cd /drone/src
- mvn clean package -DskipTests=true -pl yudao-gateway,yudao-module-system/yudao-module-system-biz,yudao-module-infra/yudao-module-infra-biz -am - mvn clean package -DskipTests=true -pl yudao-gateway,yudao-module-system/yudao-module-system-biz,yudao-module-infra/yudao-module-infra-biz -am
- name: build-jar - name: copy-jars
image: alpine image: alpine
volumes: volumes:
- name: build-output - name: build-output
path: /home/app/build path: /home/app/build
commands: commands:
- mkdir -p /home/app/build/{gateway,system,infra} - mkdir -p /home/app/build/gateway
- cp yudao-gateway/target/yudao-gateway.jar /home/app/build/gateway/app.jar - mkdir -p /home/app/build/system
- cp yudao-module-system/yudao-module-system-biz/target/yudao-module-system-biz.jar /home/app/build/system/app.jar - mkdir -p /home/app/build/infra
- cp yudao-module-infra/yudao-module-infra-biz/target//yudao-module-infra-biz.jar /home/app/build/infra/app.jar - ls -l yudao-gateway/target/ # 检查源文件是否存在
- cp yudao-gateway/target/yudao-gateway.jar /home/app/build/gateway/app.jar || echo "Failed to copy gateway jar"
- cp yudao-module-system/yudao-module-system-biz/target/yudao-module-system-biz.jar /home/app/build/system/app.jar || echo "Failed to copy system biz jar"
- cp yudao-module-infra/yudao-module-infra-biz/target/yudao-module-infra-biz.jar /home/app/build/infra/app.jar || echo "Failed to copy infra biz jar"
- cp Dockerfile /home/app/build/ - cp Dockerfile /home/app/build/
- cp docker-compose.yml /home/app/build/
- name: build-docker - name: build-docker-images
image: docker image: docker
volumes: volumes:
- name: build-output - name: build-output
@ -50,20 +55,16 @@ steps:
path: /var/run/docker.sock path: /var/run/docker.sock
commands: commands:
- cd /home/app/build - cd /home/app/build
- cp docker-compose.yml . - sed -i "s/${APP_VERSION}/${APP_VERSION}/g" docker-compose.yml
- sed -i "s/\${APP_VERSION}/${APP_VERSION}/g" docker-compose.yml - docker-compose -f docker-compose.yml up -d
- docker-compose up -d
volumes: volumes:
- name: maven-cache - name: maven-cache
host: host:
path: /home/data/maven/cache path: /home/data/maven/cache
- name: build-output
host:
path: /home/data/maven/build
- name: docker - name: docker
host: host:
path: /var/run/docker.sock path: /var/run/docker.sock
#trigger:
# event:
# - custom
# ref:
# - refs/tags/version1.1