From 88ba24034e5ec026049570a27be799533b0f2e5c Mon Sep 17 00:00:00 2001 From: Home Date: Sun, 29 Mar 2026 03:17:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4jenkins=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96=E6=B5=81=E6=B0=B4=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile | 42 ++++++++++++++++++++---------------------- package.json | 1 + 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6346b76f..a4e1e42a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,28 +11,6 @@ pipeline { ANDROID_SDK = '/opt/android-sdk' // 安卓 SDK 路径 } stages { - stage('读取 manifest 版本号(jq 稳定版)') { - steps { - script { - // 用 jq 读取(你最熟悉、最稳) - VERSION_NAME = sh( - script: "jq -r '.versionName' ./src/manifest.json", - returnStdout: true - ).trim() - - VERSION_CODE = sh( - script: "jq -r '.versionCode' ./src/manifest.json", - returnStdout: true - ).trim() - - echo "=====================================" - echo " 版本名称:${VERSION_NAME}" - echo " 版本号:${VERSION_CODE}" - echo "=====================================" - - } - } - } stage('打印环境变量') { steps { echo "使用的 UNIAPP_APP_ID:${env.UNIAPP_APP_ID}" @@ -57,6 +35,26 @@ pipeline { echo "✅ 安装 UniApp 依赖(忽略平台+开权限+强制)" sh "npm install --force --unsafe-perm --ignore-platform" } + } + steps { + script { + VERSION_NAME = sh( + script: ''' + node -p "require('json5').parse(require('fs').readFileSync('./src/manifest.json','utf8')).versionName" + ''', + returnStdout: true + ).trim() + + VERSION_CODE = sh( + script: ''' + node -p "require('json5').parse(require('fs').readFileSync('./src/manifest.json','utf8')).versionCode" + ''', + returnStdout: true + ).trim() + + echo "版本名称:${VERSION_NAME}" + echo "版本号:${VERSION_CODE}" + } } stage('打包uniapp') { steps { diff --git a/package.json b/package.json index 35c2b8e6..bad3c8ee 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "@dcloudio/uni-uts-v1": "3.0.0-4060620250520001", "@dcloudio/vite-plugin-uni": "3.0.0-4060620250520001", "@vue/runtime-core": "^3.4.21", + "json5": "^2.2.3", "sass": "1.77.0", "typescript": "^5.9.3", "vite": "5.2.8"