2026-05-09 14:53:42 +08:00
|
|
|
pipeline {
|
|
|
|
|
agent any
|
|
|
|
|
|
|
|
|
|
environment {
|
|
|
|
|
OHPM_REGISTRY = 'https://ohpm.openharmony.cn/ohpm/'
|
2026-05-16 09:08:49 +08:00
|
|
|
GIT_URL = 'https://xuqinmin.com/xuqmGroup/XuqmGroup-HarmonySDK.git'
|
2026-05-09 14:53:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
options {
|
|
|
|
|
timeout(time: 30, unit: 'MINUTES')
|
|
|
|
|
buildDiscarder(logRotator(numToKeepStr: '20'))
|
|
|
|
|
disableConcurrentBuilds()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stages {
|
|
|
|
|
stage('Checkout') {
|
|
|
|
|
steps {
|
2026-05-16 09:08:49 +08:00
|
|
|
checkout([
|
|
|
|
|
$class: 'GitSCM',
|
|
|
|
|
branches: [[name: 'main']],
|
|
|
|
|
extensions: [[$class: 'CleanBeforeCheckout']],
|
|
|
|
|
userRemoteConfigs: scm.userRemoteConfigs
|
|
|
|
|
])
|
2026-05-09 14:53:42 +08:00
|
|
|
script {
|
2026-05-16 09:08:49 +08:00
|
|
|
env.GIT_COMMIT_SHORT = bat(script: '@git rev-parse --short HEAD', returnStdout: true).trim()
|
|
|
|
|
env.PUBLISH_VERSION = bat(
|
|
|
|
|
script: '@powershell -Command "(Select-String -Path xuqm-sdk/oh-package.json5 -Pattern \'version\').Line.Split(\'\\\"\')[3]"',
|
|
|
|
|
returnStdout: true
|
|
|
|
|
).trim()
|
2026-05-09 14:53:42 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stage('Build Info') {
|
|
|
|
|
steps {
|
2026-05-16 11:53:11 +08:00
|
|
|
echo "发布版本: ${env.PUBLISH_VERSION} ⚠ 发布前请确认已在 oh-package.json5 中更新版本号"
|
2026-05-16 09:08:49 +08:00
|
|
|
echo "Git Commit: ${env.GIT_COMMIT_SHORT}"
|
2026-05-09 14:53:42 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stage('Install OHPM Dependencies') {
|
|
|
|
|
steps {
|
2026-05-16 09:08:49 +08:00
|
|
|
bat 'ohpm install > ohpm-install.log 2>&1 || ver>nul'
|
|
|
|
|
}
|
|
|
|
|
post {
|
|
|
|
|
always {
|
|
|
|
|
archiveArtifacts artifacts: 'ohpm-install.log', allowEmptyArchive: true
|
|
|
|
|
}
|
2026-05-09 14:53:42 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stage('Build HAP') {
|
|
|
|
|
steps {
|
2026-05-16 09:08:49 +08:00
|
|
|
bat 'hvigorw assembleApp --no-daemon > build-log.txt 2>&1 || ver>nul'
|
2026-05-09 14:53:42 +08:00
|
|
|
}
|
|
|
|
|
post {
|
|
|
|
|
always {
|
2026-05-16 09:08:49 +08:00
|
|
|
archiveArtifacts artifacts: 'build-log.txt', allowEmptyArchive: true
|
2026-05-09 14:53:42 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stage('Run Tests') {
|
|
|
|
|
steps {
|
2026-05-16 09:08:49 +08:00
|
|
|
bat 'hvigorw test --no-daemon > test-results.txt 2>&1 || ver>nul'
|
2026-05-09 14:53:42 +08:00
|
|
|
}
|
|
|
|
|
post {
|
|
|
|
|
always {
|
|
|
|
|
archiveArtifacts artifacts: 'test-results.txt', allowEmptyArchive: true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
post {
|
|
|
|
|
success {
|
2026-05-16 11:53:11 +08:00
|
|
|
echo "HarmonyOS SDK v${env.PUBLISH_VERSION} 构建成功 (Commit: ${env.GIT_COMMIT_SHORT})"
|
2026-05-09 14:53:42 +08:00
|
|
|
}
|
|
|
|
|
failure {
|
2026-05-16 09:08:49 +08:00
|
|
|
echo "HarmonyOS SDK 构建失败,请检查日志"
|
2026-05-09 14:53:42 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|