From f648a8be90e5e8ee02048bbc8245d4f90a56fe78 Mon Sep 17 00:00:00 2001 From: Home Date: Sun, 29 Mar 2026 03:20:32 +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 | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8cb16468..da05310d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -36,26 +36,31 @@ pipeline { sh "npm install --force --unsafe-perm --ignore-platform" } } - stage('读取 manifest 版本号(json5 终极版)') { + stage('读取 manifest 版本号 → 写入环境变量') { steps { script { - VERSION_NAME = sh( + // 1. 安装 json5(支持注释JSON) + sh 'npm install json5 --registry=https://registry.npmmirror.com' + + // 2. 读取并设置为 环境变量(全局可用) + env.versionName = sh( script: ''' node -p "require('json5').parse(require('fs').readFileSync('./src/manifest.json','utf8')).versionName" ''', returnStdout: true ).trim() - VERSION_CODE = sh( + env.versionCode = sh( script: ''' node -p "require('json5').parse(require('fs').readFileSync('./src/manifest.json','utf8')).versionCode" ''', returnStdout: true ).trim() - - echo "版本名称:${VERSION_NAME}" - echo "版本号:${VERSION_CODE}" } + + // 测试输出(你能看到成功了) + echo "✅ 版本名称:${env.versionName}" + echo "✅ 版本号:${env.versionCode}" } } stage('打包uniapp') {