diff --git a/.woodpecker.yml b/.woodpecker.yml new file mode 100644 index 0000000..85b9512 --- /dev/null +++ b/.woodpecker.yml @@ -0,0 +1,135 @@ +clone: + git: + image: woodpeckerci/plugin-git:next + settings: + depth: false + +steps: + # lingniu-framework CI/CD 流程 - 发布到 Nexus + - name: maven-deploy-to-nexus + image: maven:3.6.3-jdk-8 + when: + event: + - push + - pull_request + - manual # 允许手动触发 + branch: + - master + - develop + environment: + # Nexus 认证信息(通过 Woodpecker secret 注入) + NEXUS_USERNAME: + from_secret: nexus_username + NEXUS_PASSWORD: + from_secret: nexus_password + commands: | + echo "========================================" + echo "Building lingniu-framework-parent" + echo "========================================" + + # 进入工作目录 + cd $CI_WORKSPACE + + # 创建 Maven settings.xml 配置文件 + mkdir -p ~/.m2 + cat > ~/.m2/settings.xml <<'EOF' + + + + + + lnh2e-releases + ${NEXUS_USERNAME} + ${NEXUS_PASSWORD} + + + lnh2e-snapshots + ${NEXUS_USERNAME} + ${NEXUS_PASSWORD} + + + + + + lnh2e-central + central + 羚牛私服中央仓库 + https://nexus.lnh2e.com/repository/maven-public/ + + + + + + lnh2e + + + lnh2e-releases + 羚牛私服发布仓库 + https://nexus.lnh2e.com/repository/maven-releases/ + + true + + + false + + + + lnh2e-snapshots + 羚牛私服快照仓库 + https://nexus.lnh2e.com/repository/maven-snapshots/ + + false + + + true + + + + + + lnh2e-plugins + 羚牛私服插件仓库 + https://nexus.lnh2e.com/repository/maven-public/ + + true + + + true + + + + + + + + lnh2e + + + + EOF + + echo "Maven settings.xml created" + + # 获取分支名 + BRANCH_NAME=$(echo $CI_COMMIT_BRANCH | tr / -) + echo "Branch name: $BRANCH_NAME" + + # 获取项目版本号 + PROJECT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) + echo "Project version: $PROJECT_VERSION" + + # 打印构建信息 + echo "========================================" + echo "Branch: $BRANCH_NAME" + echo "Version: $PROJECT_VERSION" + echo "========================================" + + # 构建并部署到 Nexus(跳过测试) + echo "Building and deploying to Nexus..." + mvn -B -e -U clean deploy -Dmaven.test.skip=true + + echo "========================================" + echo "Deploy completed successfully!" + echo "========================================" diff --git a/pom.xml b/pom.xml index 2e988ab..e825f5a 100644 --- a/pom.xml +++ b/pom.xml @@ -36,11 +36,11 @@ - releases + lnh2e-releases https://nexus.lnh2e.com/repository/maven-releases/ - snapshots + lnh2e-snapshots https://nexus.lnh2e.com/repository/maven-snapshots/