Files
martial-master/.drone.yml
n72595987@gmail.com 8a779a56ac
Some checks failed
continuous-integration/drone/push Build is failing
修复 Drone CI 编译失败:合并框架和项目编译步骤
问题原因:
- 步骤1和步骤2在不同容器中执行
- Maven 本地仓库(~/.m2/repository)不共享
- 后端项目找不到已编译的 BladeX 框架依赖
- 导致 401 Unauthorized 错误(尝试从远程下载)

解决方案:
- 将"编译框架依赖"和"编译后端项目"合并为一个步骤
- 在同一个 Maven 容器中顺序执行
- 框架编译后立即可用于后端项目编译

执行流程:
1. 克隆 martial-tool 框架代码
2. 编译框架并 install 到 Maven 本地仓库
3. 切换到后端项目目录
4. 编译后端项目(可使用本地 Maven 仓库中的框架)

优势:
- Maven 本地仓库在同一容器中共享
- 无需访问远程私有仓库
- 构建更可靠和快速

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 22:00:07 +08:00

99 lines
2.4 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
kind: pipeline
type: docker
name: 武术系统后端自动部署
# 只在 main 分支触发
trigger:
branch:
- main
event:
- push
steps:
# 步骤1克隆并编译 BladeX 框架,然后编译后端项目
- name: 编译完整项目
image: maven:3.9-eclipse-temurin-17
commands:
- echo "克隆 BladeX 框架代码..."
- cd /drone/src/..
- git clone https://git.waypeak.work/martial/martial-tool.git || echo "已存在,跳过克隆"
- echo "开始编译 BladeX 框架..."
- cd martial-tool
- mvn clean install -DskipTests -q
- echo "✅ BladeX 框架编译完成,已安装到 Maven 本地仓库"
- echo "开始编译后端项目..."
- cd /drone/src
- mvn clean package -DskipTests -Dmaven.test.skip=true
- ls -lh target/blade-api.jar
- echo "✅ 后端项目编译完成"
# 步骤2传输 JAR 文件到服务器
- name: 传输构建产物
image: appleboy/drone-scp
settings:
host: 154.30.6.21
username: root
key:
from_secret: ssh_key
port: 22
target: /app/martial-backend/bin/
source:
- target/blade-api.jar
strip_components: 1
# 步骤3重启后端服务
- name: 部署到生产环境
image: appleboy/drone-ssh
settings:
host: 154.30.6.21
username: root
key:
from_secret: ssh_key
port: 22
script:
- systemctl restart martial-backend
- sleep 3
- systemctl status martial-backend --no-pager
- echo "✅ 后端部署完成"
# 步骤4健康检查
- name: 健康检查
image: curlimages/curl:latest
commands:
- sleep 15 # 等待服务启动
- curl -f http://154.30.6.21:8123/actuator/health || exit 1
- echo "✅ 健康检查通过"
# 构建通知(可选)
---
kind: pipeline
type: docker
name: 构建通知
trigger:
branch:
- main
status:
- success
- failure
steps:
- name: 发送通知
image: drillster/drone-email
settings:
host: smtp.qq.com # 邮件服务器
port: 465
from: your-email@qq.com
recipients:
- your-email@qq.com
username:
from_secret: email_username
password:
from_secret: email_password
when:
status:
- failure # 只在失败时发送邮件
depends_on:
- 武术系统后端自动部署