diff --git a/Jenkinsfile.ios b/Jenkinsfile.ios index e5a064dd..121c4610 100644 --- a/Jenkinsfile.ios +++ b/Jenkinsfile.ios @@ -8,10 +8,16 @@ pipeline { APP_DIR = "Ios/HBuilder-Hello" PROJECT_NAME = 'HBuilder-Hello' ASSETS_DIR = "${APP_DIR}/${PROJECT_NAME}/Pandora/apps/${UNIAPP_APP_ID}/www" - + // 项目配置 SCHEME_NAME = 'HBuilder' CONFIGURATION = 'Release' ARCHIVE_PATH = "${APP_DIR}//build/HBuilder.xcarchive" //归档文件输出路径 + //项目证书配置 + CERT_DIR='certificate/ios' + P12_FILE="$CERT_DIR/开发证书.p12" + P12_PASSWORD="Kup9dayLY#*" + PROFILE_FILE="$CERT_DIR/jiaixuedev.mobileprovision" + MAC_LOGIN_PWD="667788" } stages { stage('打印环境变量') { @@ -25,7 +31,6 @@ pipeline { stage('清理旧构建') { steps { sh "rm -rf dist/" // 清理 UniApp 打包生成的 dist 目录 -// sh "rm -rf ${ASSETS_DIR}" // 清理旧的 APP 资源文件目录 } } stage('安装依赖') { @@ -89,18 +94,50 @@ pipeline { } } - stage('开始归档项目') { + stage('清理旧构建') { steps { - sh """ - xcodebuild archive \\ - -project ${APP_DIR}/${PROJECT_NAME}.xcodeproj \\ - -scheme ${SCHEME_NAME} \\ - -configuration ${CONFIGURATION} \\ - -archivePath ${ARCHIVE_PATH} - """ - + sh "rm -rf dist/" // 清理 UniApp 打包生成的 dist 目录 } } + stage('安装iOS证书 & 描述文件') { + steps { + sh ''' + # 解锁系统钥匙串(必须!) + security unlock-keychain -p ${MAC_LOGIN_PWD} ~/Library/Keychains/login.keychain-db + + # 导入 p12 证书到系统 + security import ${P12_FILE} \\ + -k ~/Library/Keychains/login.keychain-db \\ + -P ${P12_PASSWORD} \\ + -A \\ + -t cert + + # 允许Xcode调用签名 + security set-key-partition-list \\ + -S apple-tool:,apple:,codesign: \\ + -s -k ${MAC_LOGIN_PWD} \\ + ~/Library/Keychains/login.keychain-db + + # 安装描述文件到系统目录 + mkdir -p ~/Library/MobileDevice/Provisioning\\ Profiles + cp ${PROFILE_FILE} ~/Library/MobileDevice/Provisioning\\ Profiles/ + + echo "✅ 证书 + 描述文件 安装完成!" + ''' + } + } +// stage('开始归档项目') { +// steps { +// sh """ +// xcodebuild archive \\ +// -project ${APP_DIR}/${PROJECT_NAME}.xcodeproj \\ +// -scheme ${SCHEME_NAME} \\ +// -configuration ${CONFIGURATION} \\ +// -archivePath ${ARCHIVE_PATH} +// """ +// +// } +// } } post {