更新jenkins脚本

main
zhangaotian 2025-10-11 19:00:10 +08:00
parent 14a2c4af7c
commit 94ba4e3010
1 changed files with 64 additions and 16 deletions

View File

@ -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 <sdk_path> <channel_path>
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}】上传符号表异常"