chore(ci): 简化 Woodpecker CI 配置并更新阿里云 ACR 认证
- 移除多余的工作流定义,简化为单一构建流程 - 删除分支触发条件,改为默认执行构建步骤 - 更新 Docker 镜像推送的目标仓库为阿里云 ACR - 更换认证凭据名称为阿里云 ACR 用户名密码 - 清理注释和冗余配置项,优化配置结构
This commit is contained in:
parent
f5039c0ab6
commit
cc3a740993
|
|
@ -1,43 +1,29 @@
|
||||||
# .woodpecker.yaml
|
# .woodpecker.yaml
|
||||||
workflows:
|
|
||||||
build-and-deploy:
|
|
||||||
name: Java应用构建与部署
|
|
||||||
# 触发条件,仅在 main/master 分支推送时运行
|
|
||||||
when:
|
|
||||||
- event: push
|
|
||||||
branch: main
|
|
||||||
- event: push
|
|
||||||
branch: master
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# 1. 使用 Maven 构建 Java 应用,并缓存依赖
|
|
||||||
- name: Java 构建
|
- name: Java 构建
|
||||||
image: maven:3.9.6-eclipse-temurin-17
|
image: maven:3.9.6-eclipse-temurin-17
|
||||||
pull: true
|
pull: true
|
||||||
commands:
|
commands:
|
||||||
- mvn clean package -DskipTests # 跳过测试以加快构建
|
- mvn clean package -DskipTests
|
||||||
|
# volumes 挂载在单工作流中可正常使用
|
||||||
volumes:
|
volumes:
|
||||||
- /tmp/maven-cache:/root/.m2 # 缓存 Maven 依赖
|
- /tmp/maven-cache:/root/.m2
|
||||||
|
|
||||||
# 2. 将构建好的 JAR 文件打包为 Docker 镜像
|
|
||||||
- name: Docker 构建
|
- name: Docker 构建
|
||||||
image: docker:latest
|
image: docker:latest
|
||||||
pull: true
|
pull: true
|
||||||
commands:
|
commands:
|
||||||
- docker build -t registry.cn-zhangjiakou.aliyuncs.com/abhors/demo:latest .
|
- docker build -t registry.cn-zhangjiakou.aliyuncs.com/abhors/demo:latest .
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock # ⚠️ Docker in Docker 挂载
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
|
||||||
# 3. 将打包好的镜像推送到 Docker Hub
|
|
||||||
- name: 镜像推送
|
- name: 镜像推送
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
settings:
|
settings:
|
||||||
# ⚠️ 关键配置:必须准确填写
|
|
||||||
repo: registry.cn-zhangjiakou.aliyuncs.com/abhors/demo
|
repo: registry.cn-zhangjiakou.aliyuncs.com/abhors/demo
|
||||||
registry: registry.cn-zhangjiakou.aliyuncs.com
|
|
||||||
tags: latest
|
tags: latest
|
||||||
dockerfile: ./Dockerfile
|
registry: registry.cn-zhangjiakou.aliyuncs.com
|
||||||
username:
|
username:
|
||||||
from_secret: docker_hub_user # 从 Woodpecker UI 获取的 Docker Hub 用户名
|
from_secret: aliyun_acr_username
|
||||||
password:
|
password:
|
||||||
from_secret: docker_hub_pass # 从 Woodpecker UI 获取的 Docker Hub 密码或 Token
|
from_secret: aliyun_acr_password
|
||||||
Loading…
Reference in New Issue