- 新增 compose.production.yaml 和 compose.production.server.yaml 部署配置 - 添加 nginx.dev.xuqinmin.com.conf 和 nginx.sentry.xuqinmin.com.conf 反向代理配置 - 创建详细的部署指南文档 deploy/README.md,涵盖架构设计和部署步骤 - 添加前端访问文档 web/README.md,包含线上地址和接口说明 - 补充平台文档总览 README.md,整合各模块文档入口 - 配置多服务容器化部署,包括 tenant-service、im-service、push-service 等 - 设置外部数据库和 Redis 连接配置,确保服务间正确通信 - 配置 WebSocket 和 API 路由转发规则,支持实时通信和版本更新服务
108 行
3.8 KiB
Groovy
108 行
3.8 KiB
Groovy
pipeline {
|
||
agent any
|
||
|
||
parameters {
|
||
string(name: 'BRANCH', defaultValue: 'main', description: 'Git 分支名')
|
||
string(name: 'VERSION', defaultValue: '', description: '发布版本号(留空使用 oh-package.json5 中的 version)')
|
||
booleanParam(name: 'RUN_TESTS', defaultValue: true, description: '是否运行测试')
|
||
booleanParam(name: 'PUBLISH', defaultValue: true, description: '是否发布到 OHPM 仓库')
|
||
}
|
||
|
||
environment {
|
||
OHPM_REGISTRY = 'https://ohpm.openharmony.cn/ohpm/'
|
||
GIT_URL = 'https://xuqinmin.com/xuqinmin12/XuqmGroup-HarmonySDK.git'
|
||
}
|
||
|
||
options {
|
||
timeout(time: 30, unit: 'MINUTES')
|
||
buildDiscarder(logRotator(numToKeepStr: '20'))
|
||
disableConcurrentBuilds()
|
||
}
|
||
|
||
stages {
|
||
stage('Checkout') {
|
||
steps {
|
||
checkout scm
|
||
script {
|
||
env.GIT_COMMIT_SHORT = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
|
||
if (params.VERSION?.trim()) {
|
||
sh "sed -i '' 's/\"version\": *\"[^\"]*\"/\"version\": \"${params.VERSION}\"/' xuqm-sdk/oh-package.json5"
|
||
sh "sed -i '' 's/\"version\": *\"[^\"]*\"/\"version\": \"${params.VERSION}\"/' oh-package.json5 2>/dev/null || true"
|
||
}
|
||
env.PUBLISH_VERSION = sh(script: 'grep "version" xuqm-sdk/oh-package.json5 | head -1 | sed "s/.*: *\\"\\(.*\\)\\".*/\\1/"', returnStdout: true).trim()
|
||
}
|
||
}
|
||
}
|
||
|
||
stage('Build Info') {
|
||
steps {
|
||
script {
|
||
echo "🚀 构建分支: ${params.BRANCH}"
|
||
echo "🏷️ 发布版本: ${env.PUBLISH_VERSION}"
|
||
echo "🔨 Git Commit: ${env.GIT_COMMIT_SHORT}"
|
||
}
|
||
}
|
||
}
|
||
|
||
stage('Install OHPM Dependencies') {
|
||
steps {
|
||
sh 'ohpm install 2>&1 | tee ohpm-install.log || true'
|
||
}
|
||
}
|
||
|
||
stage('Build HAP') {
|
||
steps {
|
||
sh 'hvigorw assembleApp --no-daemon 2>&1 | tee build-log.txt || true'
|
||
}
|
||
post {
|
||
always {
|
||
archiveArtifacts artifacts: 'build-log.txt, ohpm-install.log', allowEmptyArchive: true
|
||
}
|
||
}
|
||
}
|
||
|
||
stage('Run Tests') {
|
||
when { expression { return params.RUN_TESTS } }
|
||
steps {
|
||
sh 'hvigorw test --no-daemon 2>&1 | tee test-results.txt || true'
|
||
}
|
||
post {
|
||
always {
|
||
archiveArtifacts artifacts: 'test-results.txt', allowEmptyArchive: true
|
||
}
|
||
}
|
||
}
|
||
|
||
stage('Publish to OHPM') {
|
||
when {
|
||
allOf {
|
||
branch 'main'
|
||
expression { return params.PUBLISH }
|
||
}
|
||
}
|
||
steps {
|
||
withCredentials([usernamePassword(credentialsId: 'ohpm-credentials', passwordVariable: 'OHPM_PASS', usernameVariable: 'OHPM_USER')]) {
|
||
sh """
|
||
ohpm login -u ${OHPM_USER} -p ${OHPM_PASS} --registry ${OHPM_REGISTRY}
|
||
cd xuqm-sdk && ohpm publish --registry ${OHPM_REGISTRY} 2>&1 | tee publish.log || true
|
||
"""
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
post {
|
||
success {
|
||
script {
|
||
echo "✅ HarmonyOS SDK v${env.PUBLISH_VERSION} 构建成功 (Commit: ${env.GIT_COMMIT_SHORT})"
|
||
if (params.PUBLISH) {
|
||
echo "📦 已发布到 OHPM 仓库: ${OHPM_REGISTRY}"
|
||
}
|
||
}
|
||
}
|
||
failure {
|
||
echo "❌ HarmonyOS SDK 构建失败,请检查日志"
|
||
}
|
||
}
|
||
}
|