Files
yexuejc-base/.gitee-ci.yml
T
yexuejc 19d8e9f4c4
CI - Build and Quality Check / build (push) Has been cancelled
CI - Build and Quality Check / security-check (push) Has been cancelled
CI - Build and Quality Check / release (push) Has been cancelled
[P3] 修复 CI/CD 配置 — 审计纠错
- Gitea ci.yaml: 改用 ./mvnw,修复 gitea.event_name 变量,去掉硬编码项目名
- Gitea package.yaml: 修复 GITEA_REF_NAME/GITEA_ENV,去掉硬编码项目名
- GitHub ci.yaml: 按分支自动检测 JDK 版本(避免跨版本编译失败),release 仅 tag 触发
- GitLab ci.yml: 简化 only 规则,修正缩进
- Gitee: 删除错误的 gitee.yml(混用语法),新增 .gitee-ci.yml(GitLab CI 兼容格式)
2026-04-18 16:24:38 +08:00

220 lines
4.5 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.
# Gitee Go CI/CD 配置
# Gitee CI 语法基于 GitLab CI,文件名必须为 .gitee-ci.yml
# 放置在项目根目录,推送后自动触发流水线
#
# 使用方式:
# 1. 开启 Gitee 仓库的 CI/CD 功能(管理 > CI/CD)
# 2. 确保 .gitee-ci.yml 在项目根目录
# 3. 推送代码后自动触发
image: maven:3.9-eclipse-temurin-21
stages:
- build
- test
- quality
- security
- package
- release
variables:
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
cache:
key: "${CI_COMMIT_REF_SLUG}"
paths:
- .m2/repository/
# ============================================
# 构建阶段 — 根据分支自动选择 JDK
# ============================================
build:java21:
stage: build
image: maven:3.9-eclipse-temurin-21
script:
- ./mvnw -B clean compile
artifacts:
paths:
- target/classes/
expire_in: 1 hour
only:
- master
- jre21
build:java17:
stage: build
image: maven:3.9-eclipse-temurin-17
script:
- ./mvnw -B clean compile
artifacts:
paths:
- target/classes/
expire_in: 1 hour
only:
- master
- jre17
build:java11:
stage: build
image: maven:3.9-eclipse-temurin-11
script:
- ./mvnw -B clean compile
artifacts:
paths:
- target/classes/
expire_in: 1 hour
only:
- master
- jre11
build:java8:
stage: build
image: maven:3.9-eclipse-temurin-8
script:
- ./mvnw -B clean compile
artifacts:
paths:
- target/classes/
expire_in: 1 hour
only:
- master
- jre8
# ============================================
# 测试阶段 — 各 JDK 独立跑测试
# ============================================
test:java21:
stage: test
image: maven:3.9-eclipse-temurin-21
script:
- ./mvnw -B test
artifacts:
reports:
junit: target/surefire-reports/*.xml
paths:
- target/surefire-reports/
- target/site/jacoco/
expire_in: 7 days
only:
- master
- jre21
test:java17:
stage: test
image: maven:3.9-eclipse-temurin-17
script:
- ./mvnw -B test
artifacts:
reports:
junit: target/surefire-reports/*.xml
paths:
- target/surefire-reports/
expire_in: 7 days
only:
- master
- jre17
test:java11:
stage: test
image: maven:3.9-eclipse-temurin-11
script:
- ./mvnw -B test
artifacts:
reports:
junit: target/surefire-reports/*.xml
paths:
- target/surefire-reports/
expire_in: 7 days
only:
- master
- jre11
test:java8:
stage: test
image: maven:3.9-eclipse-temurin-8
script:
- ./mvnw -B test
artifacts:
reports:
junit: target/surefire-reports/*.xml
paths:
- target/surefire-reports/
expire_in: 7 days
only:
- master
- jre8
# ============================================
# 代码质量检查 (仅 Java 21)
# ============================================
checkstyle:
stage: quality
image: maven:3.9-eclipse-temurin-21
script:
- ./mvnw -B checkstyle:check
artifacts:
paths:
- target/checkstyle-result.xml
expire_in: 7 days
allow_failure: true
pmd:
stage: quality
image: maven:3.9-eclipse-temurin-21
script:
- ./mvnw -B pmd:pmd
artifacts:
paths:
- target/pmd-report.xml
expire_in: 7 days
allow_failure: true
# ============================================
# 安全扫描 (仅 master/jre21)
# ============================================
owasp-check:
stage: security
image: maven:3.9-eclipse-temurin-21
variables:
MAVEN_OPTS: "-Xmx2048m -Dmaven.repo.local=.m2/repository"
script:
- ./mvnw -B org.owasp:dependency-check-maven:check
artifacts:
paths:
- target/dependency-check-report.html
expire_in: 14 days
allow_failure: true
only:
- master
- jre21
# ============================================
# 打包
# ============================================
package:
stage: package
image: maven:3.9-eclipse-temurin-21
script:
- ./mvnw -B package -DskipTests
artifacts:
paths:
- target/*.jar
expire_in: 30 days
# ============================================
# 发布到 Maven Central (仅 tag, 手动触发)
# ============================================
release:maven-central:
stage: release
image: maven:3.9-eclipse-temurin-21
script:
- ./mvnw -B deploy -Dgpg.skip=false
only:
- tags
when: manual
# 需要在 Gitee 仓库设置中配置 CI/CD 变量:
# MAVEN_CENTRAL_USERNAME — OSSRH 用户名
# MAVEN_CENTRAL_PASSWORD — OSSRH 密码
# GPG_PRIVATE_KEY — GPG 私钥 (ASCII armored)
# GPG_PASSPHRASE — GPG 密钥密码