From 94ba4e30101b2941e4d7d8ac3bf86a2dc6d1e8f4 Mon Sep 17 00:00:00 2001 From: zhangaotian <8474238@qq.com> Date: Sat, 11 Oct 2025 19:00:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0jenkins=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jenkins_android_release_new.groovy | 80 +++++++++++++++---- 1 file changed, 64 insertions(+), 16 deletions(-) diff --git a/Tool/build_env/jenkins_android_release_new.groovy b/Tool/build_env/jenkins_android_release_new.groovy index c528c04028c..fae7ed9dec9 100644 --- a/Tool/build_env/jenkins_android_release_new.groovy +++ b/Tool/build_env/jenkins_android_release_new.groovy @@ -135,27 +135,71 @@ pipeline { sh "cp /Users/mayuanzheng/Builds/local_env.sh $WORKSPACE/Tool/build_tools/" } } + stage('修改渠道文件夹') { + steps { + script { + try { + // 先安装pyyaml + sh "pip3 install pyyaml --user" + // 调用python脚本修改渠道文件夹 + echo "根据 [${params.Channel}] 渠道修改文件夹" + def channelPath = "${WORKSPACE}/Tool/Channels/${CHANNEL_PARAM}" + def sdkPath = "${WORKSPACE}/Tool/sdk_packages" + echo "Channel Path: ${channelPath}" + echo "SDK Path: ${sdkPath}" + // python脚本: Tool/py_tools/PreHandle.py + sh "chmod +x $WORKSPACE/Tool/py_tools/PreHandle.py" + // 使用 returnStatus 获取脚本的退出码 + def pythonResult = sh(script: "python3 $WORKSPACE/Tool/py_tools/PreHandle.py ${sdkPath} ${channelPath}", returnStatus: true) + if (pythonResult != 0) { + def message = "【${PLATFORM_PARAM}】【${VERSION_PARAM}】【Release】【${CHANNEL_PARAM}】修改渠道文件夹失败: pythonResult=${pythonResult}" + SendMessageToWechat(message) + error("Failure of the '修改渠道文件夹' stage") + } + } catch (err) { + def message = "【${PLATFORM_PARAM}】【${VERSION_PARAM}】【Release】【${CHANNEL_PARAM}】根据渠道修改工程失败" + SendMessageToWechat(message) + error("Failure of the '修改渠道文件夹' stage") + } + } + } + } stage('根据渠道修改工程') { steps { - echo "根据 [${params.Channel}] 渠道修改工程" - sh "chmod +x $WORKSPACE/Tool/build_tools/modify_project_by_channel.sh" - sh "$WORKSPACE/Tool/build_tools/modify_project_by_channel.sh $WORKSPACE ${CHANNEL_PARAM}" + script { + try { + echo "根据 [${params.Channel}] 渠道修改工程" + sh "chmod +x $WORKSPACE/Tool/build_tools/modify_project_by_channel.sh" + sh "$WORKSPACE/Tool/build_tools/modify_project_by_channel.sh $WORKSPACE ${CHANNEL_PARAM}" + } catch (err) { + def message = "【${PLATFORM_PARAM}】【${VERSION_PARAM}】【Release】【${CHANNEL_PARAM}】根据渠道修改工程失败" + SendMessageToWechat(message) + error("Failure of the '根据渠道修改工程' stage") + } + } } } stage('根据渠道获取相关参数') { steps { script { - echo "根据 [${params.Channel}] 渠道获取相关参数" - def playersettings = "$WORKSPACE/Tool/Channels/$CHANNEL_PARAM/ChannelSetting.txt" - sh "chmod +x $WORKSPACE/Tool/build_tools/get_build_version.sh" - sh "chmod +x $WORKSPACE/Tool/build_tools/get_build_upload_path.sh" - sh "chmod +x $WORKSPACE/Tool/build_tools/get_build_assets_end_point.sh" - VERSION_PARAM = sh(script: "$WORKSPACE/Tool/build_tools/get_build_version.sh $playersettings", returnStdout: true).trim() - OSS_UPLOAD_PATH_PARAM = sh(script: "$WORKSPACE/Tool/build_tools/get_build_upload_path.sh $playersettings", returnStdout: true).trim() - ASSETS_END_POINT_PARAM = sh(script: "$WORKSPACE/Tool/build_tools/get_build_assets_end_point.sh $playersettings", returnStdout: true).trim() - BUILD_PATH = "Builds/$CHANNEL_PARAM/$PLATFORM_PARAM/$VERSION_PARAM" - log_path="$BUILD_PATH/build.log" - echo "获取到的版本是 ${VERSION_PARAM}, 获取到的上传地址是 ${OSS_UPLOAD_PATH_PARAM},获取到的assets-oss-endpoint是 ${ASSETS_END_POINT_PARAM}" + try { + echo "根据 [${params.Channel}] 渠道获取相关参数" + def playersettings = "${WORKSPACE}/Tool/Channels/${CHANNEL_PARAM}/ChannelSetting.yaml" + // 1. 读取并解析 YAML,得到一个 Groovy Map + def cfg = readYaml(file: playersettings) + // 2. 提取字段 根据 YAML 键名取值 + VERSION_PARAM = (cfg?.Version ?: '').trim() + OSS_UPLOAD_PATH_PARAM = (cfg?.OssRemoteUploadPath ?: '').trim() + ASSETS_END_POINT_PARAM = (cfg?.AssetsEndPoint ?: '').trim() + // 3.其他数据 + BUILD_PATH = "Builds/$CHANNEL_PARAM/$PLATFORM_PARAM/$VERSION_PARAM" + log_path="$BUILD_PATH/build.log" + echo "获取到的版本是 ${VERSION_PARAM}, 获取到的上传地址是 ${OSS_UPLOAD_PATH_PARAM},获取到的assets-oss-endpoint是 ${ASSETS_END_POINT_PARAM}" + } catch (err) { + def message = "【${PLATFORM_PARAM}】【${VERSION_PARAM}】【Release】【${CHANNEL_PARAM}】根据渠道获取相关参数失败" + SendMessageToWechat(message) + error("Failure of the '根据渠道获取相关参数' stage") + } } } } @@ -239,9 +283,13 @@ pipeline { // 增量更新不需要上传符号表 sh "chmod +x $WORKSPACE/Tool/build_tools/upload_symbol_file.sh" if (params.Build_InitApp == true){ - def playersettings = "$WORKSPACE/Tool/Channels/$CHANNEL_PARAM/ChannelSetting.txt" + def playersettings = "${WORKSPACE}/Tool/Channels/${CHANNEL_PARAM}/ChannelSetting.yaml" def symbol_path="$WORKSPACE/Builds/$CHANNEL_PARAM/$PLATFORM_PARAM/$VERSION_PARAM" - def upload_result=sh(script: "$WORKSPACE/Tool/build_tools/upload_symbol_file.sh ${VERSION_PARAM} ${PLATFORM_PARAM} ${symbol_path} ${playersettings}", returnStatus: true, returnStdout: false) + + def crashsightConfig = cfg?."CrashSight_${PLATFORM_PARAM}" + def crashsightId = (crashsightConfig?.id ?: '').trim() + def crashsightKey = (crashsightConfig?.key ?: '').trim() + def upload_result = sh(script: "$WORKSPACE/Tool/build_tools/upload_symbol_file.sh ${VERSION_PARAM} ${PLATFORM_PARAM} ${symbol_path} ${crashsightId} ${crashsightKey}", returnStatus: true, returnStdout: false) if(upload_result != 0) { def message = "【${PLATFORM_PARAM}】【${VERSION_PARAM}】【Release】【${CHANNEL_PARAM}】上传符号表异常"