From 0025458a72844790187a7eb6aaf714e1d3ce8b6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E5=B2=A9?= Date: Mon, 30 Mar 2026 16:32:46 +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 | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/Jenkinsfile-ios b/Jenkinsfile-ios index f11ec853..32d307a2 100644 --- a/Jenkinsfile-ios +++ b/Jenkinsfile-ios @@ -225,23 +225,36 @@ pipeline { //).trim() JWT_TOKEN = sh( script: ''' - node -e " + node -e + const fs = require('fs'); const jwt = require('jsonwebtoken'); - const privateKey = `''' + p8 + '''`; + + // 从 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, - aud: 'appstoreconnect-v1' - }, - privateKey, - { - algorithm: 'ES256', - header: { kid: '""' + API_KEY + '""' } - } + { + 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); - " ''', returnStdout: true ).trim()