2026-05-09 14:53:42 +08:00
|
|
|
pipeline {
|
|
|
|
|
agent any
|
|
|
|
|
|
|
|
|
|
environment {
|
|
|
|
|
NEXUS_REGISTRY = 'https://nexus.xuqinmin.com/repository/npm-hosted/'
|
2026-05-16 09:08:46 +08:00
|
|
|
GIT_URL = 'https://xuqinmin.com/xuqmGroup/XuqmGroup-Vue3SDK.git'
|
2026-05-09 14:53:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
options {
|
|
|
|
|
timeout(time: 20, unit: 'MINUTES')
|
|
|
|
|
buildDiscarder(logRotator(numToKeepStr: '20'))
|
|
|
|
|
disableConcurrentBuilds()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stages {
|
|
|
|
|
stage('Checkout') {
|
|
|
|
|
steps {
|
2026-05-16 09:08:46 +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:46 +08:00
|
|
|
env.GIT_COMMIT_SHORT = bat(script: '@git rev-parse --short HEAD', returnStdout: true).trim()
|
|
|
|
|
env.PUBLISH_VERSION = bat(script: '@node -p "require(\'./package.json\').version"', returnStdout: true).trim()
|
2026-05-09 14:53:42 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stage('Build Info') {
|
|
|
|
|
steps {
|
2026-05-16 11:53:10 +08:00
|
|
|
echo "发布版本: ${env.PUBLISH_VERSION} ⚠ 发布前请确认已在 package.json 中更新版本号"
|
2026-05-16 09:08:46 +08:00
|
|
|
echo "Git Commit: ${env.GIT_COMMIT_SHORT}"
|
2026-05-09 14:53:42 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stage('Install Dependencies') {
|
|
|
|
|
steps {
|
2026-05-16 09:08:46 +08:00
|
|
|
bat 'npm ci'
|
2026-05-09 14:53:42 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stage('Type Check') {
|
|
|
|
|
steps {
|
2026-05-16 09:08:46 +08:00
|
|
|
bat 'npm run type-check'
|
2026-05-09 14:53:42 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stage('Build') {
|
|
|
|
|
steps {
|
2026-05-16 09:08:46 +08:00
|
|
|
bat 'npm run build'
|
2026-05-09 14:53:42 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stage('Tests') {
|
|
|
|
|
steps {
|
2026-05-16 09:08:46 +08:00
|
|
|
bat 'npm run test > test-results.txt 2>&1 || ver>nul'
|
2026-05-09 14:53:42 +08:00
|
|
|
}
|
|
|
|
|
post {
|
|
|
|
|
always {
|
|
|
|
|
archiveArtifacts artifacts: 'test-results.txt', allowEmptyArchive: true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stage('Publish to Nexus') {
|
|
|
|
|
steps {
|
2026-05-16 09:08:46 +08:00
|
|
|
withCredentials([usernamePassword(credentialsId: 'NEXUS_CREDS', passwordVariable: 'NPM_PASS', usernameVariable: 'NPM_USER')]) {
|
2026-05-16 12:25:32 +08:00
|
|
|
bat """
|
2026-05-16 12:41:43 +08:00
|
|
|
powershell -NonInteractive -Command "Set-Content .npmrc ('//nexus.xuqinmin.com/repository/npm-hosted/:_auth=' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(\$env:NPM_USER + ':' + \$env:NPM_PASS))) -Encoding ASCII"
|
2026-05-16 12:25:32 +08:00
|
|
|
npm publish --registry %NEXUS_REGISTRY%
|
|
|
|
|
"""
|
2026-05-16 09:08:46 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
post {
|
|
|
|
|
always {
|
|
|
|
|
bat 'del .npmrc 2>nul || exit 0'
|
2026-05-09 14:53:42 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-05-18 21:12:57 +08:00
|
|
|
|
|
|
|
|
stage('Publish Private SDK to Nexus') {
|
|
|
|
|
steps {
|
|
|
|
|
withCredentials([usernamePassword(credentialsId: 'NEXUS_CREDS', passwordVariable: 'NPM_PASS', usernameVariable: 'NPM_USER')]) {
|
|
|
|
|
bat """
|
|
|
|
|
powershell -NonInteractive -Command "Set-Content .npmrc ('//nexus.xuqinmin.com/repository/npm-hosted/:_auth=' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(\$env:NPM_USER + ':' + \$env:NPM_PASS))) -Encoding ASCII"
|
2026-05-18 21:21:18 +08:00
|
|
|
copy package.json package.json.bak
|
|
|
|
|
copy package.private.json package.json
|
2026-05-18 21:12:57 +08:00
|
|
|
npm publish --registry %NEXUS_REGISTRY%
|
|
|
|
|
move /Y package.json.bak package.json
|
|
|
|
|
"""
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
post {
|
|
|
|
|
always {
|
|
|
|
|
bat 'del .npmrc 2>nul || exit 0'
|
|
|
|
|
bat 'if exist package.json.bak move /Y package.json.bak package.json'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-05-09 14:53:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
post {
|
|
|
|
|
success {
|
2026-05-16 11:53:10 +08:00
|
|
|
echo "Vue3 SDK v${env.PUBLISH_VERSION} 构建成功 (Commit: ${env.GIT_COMMIT_SHORT})"
|
2026-05-09 14:53:42 +08:00
|
|
|
}
|
|
|
|
|
failure {
|
2026-05-16 09:08:46 +08:00
|
|
|
echo "Vue3 SDK 构建失败,请检查日志"
|
2026-05-09 14:53:42 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|