添加 Woodpecker CI/CD 配置实现自动发布到 Nexus
This commit is contained in:
135
.woodpecker.yml
Normal file
135
.woodpecker.yml
Normal file
@@ -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'
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
|
||||||
|
|
||||||
|
<servers>
|
||||||
|
<server>
|
||||||
|
<id>lnh2e-releases</id>
|
||||||
|
<username>${NEXUS_USERNAME}</username>
|
||||||
|
<password>${NEXUS_PASSWORD}</password>
|
||||||
|
</server>
|
||||||
|
<server>
|
||||||
|
<id>lnh2e-snapshots</id>
|
||||||
|
<username>${NEXUS_USERNAME}</username>
|
||||||
|
<password>${NEXUS_PASSWORD}</password>
|
||||||
|
</server>
|
||||||
|
</servers>
|
||||||
|
|
||||||
|
<mirrors>
|
||||||
|
<mirror>
|
||||||
|
<id>lnh2e-central</id>
|
||||||
|
<mirrorOf>central</mirrorOf>
|
||||||
|
<name>羚牛私服中央仓库</name>
|
||||||
|
<url>https://nexus.lnh2e.com/repository/maven-public/</url>
|
||||||
|
</mirror>
|
||||||
|
</mirrors>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>lnh2e</id>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>lnh2e-releases</id>
|
||||||
|
<name>羚牛私服发布仓库</name>
|
||||||
|
<url>https://nexus.lnh2e.com/repository/maven-releases/</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>lnh2e-snapshots</id>
|
||||||
|
<name>羚牛私服快照仓库</name>
|
||||||
|
<url>https://nexus.lnh2e.com/repository/maven-snapshots/</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<pluginRepositories>
|
||||||
|
<pluginRepository>
|
||||||
|
<id>lnh2e-plugins</id>
|
||||||
|
<name>羚牛私服插件仓库</name>
|
||||||
|
<url>https://nexus.lnh2e.com/repository/maven-public/</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</pluginRepository>
|
||||||
|
</pluginRepositories>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
<activeProfiles>
|
||||||
|
<activeProfile>lnh2e</activeProfile>
|
||||||
|
</activeProfiles>
|
||||||
|
|
||||||
|
</settings>
|
||||||
|
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 "========================================"
|
||||||
4
pom.xml
4
pom.xml
@@ -36,11 +36,11 @@
|
|||||||
|
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
<repository>
|
<repository>
|
||||||
<id>releases</id>
|
<id>lnh2e-releases</id>
|
||||||
<url>https://nexus.lnh2e.com/repository/maven-releases/</url>
|
<url>https://nexus.lnh2e.com/repository/maven-releases/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<snapshotRepository>
|
<snapshotRepository>
|
||||||
<id>snapshots</id>
|
<id>lnh2e-snapshots</id>
|
||||||
<url>https://nexus.lnh2e.com/repository/maven-snapshots/</url>
|
<url>https://nexus.lnh2e.com/repository/maven-snapshots/</url>
|
||||||
</snapshotRepository>
|
</snapshotRepository>
|
||||||
</distributionManagement>
|
</distributionManagement>
|
||||||
|
|||||||
Reference in New Issue
Block a user