From 4fa0e021fa2f466a33e2e5b382bed80d60734151 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E5=B2=A9?= Date: Mon, 30 Mar 2026 16:35:02 +0800 Subject: [PATCH] =?UTF-8?q?JLBA202505130001=5F=E5=85=B3=E4=BA=8E=E5=90=89?= =?UTF-8?q?=E6=9E=97=E9=93=B6=E8=A1=8C=E6=96=B0=E5=BB=BAAI=E6=99=BA?= =?UTF-8?q?=E8=83=BD=E5=9F=B9=E8=AE=AD=E7=B3=BB=E7=BB=9F=E7=9A=84=E9=9C=80?= =?UTF-8?q?=E6=B1=82=5F=E5=AE=8C=E5=96=84=E4=BB=A3=E7=A0=81=E8=A7=84?= =?UTF-8?q?=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile-ios | 42 +++++------------------------------------- 1 file changed, 5 insertions(+), 37 deletions(-) diff --git a/Jenkinsfile-ios b/Jenkinsfile-ios index 32d307a2..bdbb5e28 100644 --- a/Jenkinsfile-ios +++ b/Jenkinsfile-ios @@ -219,48 +219,16 @@ pipeline { stage('🔐 生成 JWT') { steps { script { - //JWT_TOKEN = sh( - // script: "node ${CERT_DIR}/generate-jwt.js", - // returnStdout: true - //).trim() + // 一行式 node -e "代码" 必须写在同一行! JWT_TOKEN = sh( script: ''' - node -e - const fs = require('fs'); - const jwt = require('jsonwebtoken'); - - // 从 Jenkins 环境变量获取 - const API_KEY = process.env.API_KEY; - const API_ISSUER = process.env.API_ISSUER; - const P8_FILE = process.env.P8_FILE; - - // 读取 p8 私钥 - const privateKey = fs.readFileSync(P8_FILE, 'utf8'); - - // 生成 JWT(苹果标准格式) - const token = jwt.sign( - { - iss: API_ISSUER, - exp: Math.floor(Date.now() / 1000) + 1200, // 20分钟 - aud: 'appstoreconnect-v1' - }, - privateKey, - { - algorithm: 'ES256', - header: { - kid: API_KEY, - alg: 'ES256' - } - } - ); - // 输出 JWT(Jenkins 会捕获这个值) - console.log(token); - ''', +node -e "const fs=require('fs');const jwt=require('jsonwebtoken');const privateKey=fs.readFileSync(process.env.P8_FILE,'utf8');const token=jwt.sign({iss:process.env.API_ISSUER,exp:Math.floor(Date.now()/1000)+1200,aud:'appstoreconnect-v1'},privateKey,{algorithm:'ES256',header:{kid:process.env.API_KEY}});console.log(token);" +''', returnStdout: true ).trim() - } - echo "✅ JWT 生成成功${JWT_TOKEN}" + echo "✅ JWT 生成成功:${JWT_TOKEN}" + } } }