136 lines
4.2 KiB
YAML
136 lines
4.2 KiB
YAML
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 "========================================"
|