From cc3a7409939e5b5d7f5985dfd86356556dbd7a8b Mon Sep 17 00:00:00 2001 From: gxl Date: Tue, 2 Jun 2026 13:40:34 +0800 Subject: [PATCH] =?UTF-8?q?chore(ci):=20=E7=AE=80=E5=8C=96=20Woodpecker=20?= =?UTF-8?q?CI=20=E9=85=8D=E7=BD=AE=E5=B9=B6=E6=9B=B4=E6=96=B0=E9=98=BF?= =?UTF-8?q?=E9=87=8C=E4=BA=91=20ACR=20=E8=AE=A4=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除多余的工作流定义,简化为单一构建流程 - 删除分支触发条件,改为默认执行构建步骤 - 更新 Docker 镜像推送的目标仓库为阿里云 ACR - 更换认证凭据名称为阿里云 ACR 用户名密码 - 清理注释和冗余配置项,优化配置结构 --- .woodpecker.yaml | 66 +++++++++++++++++++----------------------------- 1 file changed, 26 insertions(+), 40 deletions(-) diff --git a/.woodpecker.yaml b/.woodpecker.yaml index 03f2123..3a86e1c 100644 --- a/.woodpecker.yaml +++ b/.woodpecker.yaml @@ -1,43 +1,29 @@ # .woodpecker.yaml -workflows: - build-and-deploy: - name: Java应用构建与部署 - # 触发条件,仅在 main/master 分支推送时运行 - when: - - event: push - branch: main - - event: push - branch: master +steps: + - name: Java 构建 + image: maven:3.9.6-eclipse-temurin-17 + pull: true + commands: + - mvn clean package -DskipTests + # volumes 挂载在单工作流中可正常使用 + volumes: + - /tmp/maven-cache:/root/.m2 - steps: - # 1. 使用 Maven 构建 Java 应用,并缓存依赖 - - name: Java 构建 - image: maven:3.9.6-eclipse-temurin-17 - pull: true - commands: - - mvn clean package -DskipTests # 跳过测试以加快构建 - volumes: - - /tmp/maven-cache:/root/.m2 # 缓存 Maven 依赖 + - name: Docker 构建 + image: docker:latest + pull: true + commands: + - docker build -t registry.cn-zhangjiakou.aliyuncs.com/abhors/demo:latest . + volumes: + - /var/run/docker.sock:/var/run/docker.sock - # 2. 将构建好的 JAR 文件打包为 Docker 镜像 - - name: Docker 构建 - image: docker:latest - pull: true - commands: - - docker build -t registry.cn-zhangjiakou.aliyuncs.com/abhors/demo:latest . - volumes: - - /var/run/docker.sock:/var/run/docker.sock # ⚠️ Docker in Docker 挂载 - - # 3. 将打包好的镜像推送到 Docker Hub - - name: 镜像推送 - image: plugins/docker - settings: - # ⚠️ 关键配置:必须准确填写 - repo: registry.cn-zhangjiakou.aliyuncs.com/abhors/demo - registry: registry.cn-zhangjiakou.aliyuncs.com - tags: latest - dockerfile: ./Dockerfile - username: - from_secret: docker_hub_user # 从 Woodpecker UI 获取的 Docker Hub 用户名 - password: - from_secret: docker_hub_pass # 从 Woodpecker UI 获取的 Docker Hub 密码或 Token \ No newline at end of file + - name: 镜像推送 + image: plugins/docker + settings: + repo: registry.cn-zhangjiakou.aliyuncs.com/abhors/demo + tags: latest + registry: registry.cn-zhangjiakou.aliyuncs.com + username: + from_secret: aliyun_acr_username + password: + from_secret: aliyun_acr_password \ No newline at end of file