NLDClient-yudde/Tool/build_env/jenkins_android_dev.groovy

522 lines
28 KiB
Groovy
Raw Normal View History

2024-09-24 17:39:15 +08:00
// 对应管线任务参数
def PLATFORM_PARAM = "Android"
def PROFILE_PARAM = "Debug"
def APK_NAME = "NLDBuild.apk"
// 构建时候的参数
def CHANNEL_PARAM = params.Channel
def DEBUGBUILD_PARAM = params.DebugBuild
def HOTUPDATE_PARAM = params.Enable_Hot_Update
def AAB_PARAM = params.AAB
2025-10-15 16:50:30 +08:00
def OBFUZ = params.Obfuz
def DEV_PARAM = true
2024-12-03 13:09:25 +08:00
def ANDROIDKEYSTORE = "/Users/mayuanzheng/key/phxh_android.keystore"
def ANDROIDKEYALIAS = "avery"
2025-10-16 13:27:01 +08:00
def UPLOAD_SYMBOL = params.UploadSymbol
def PACKAGE_HARDENING = params.PackageHardening
2024-09-24 17:39:15 +08:00
// Jenkins 归档地址
def ARTIFACT_URL = "http://${env.PHXH_BUILDER_IP_ADDRESS}:8080/job/${env.JOB_NAME}/"
2025-10-20 16:34:03 +08:00
def VERSION_PARAM = "尚未获取" // 版本号 根据项目获取
2025-06-04 14:09:30 +08:00
def OSS_UPLOAD_PATH_PARAM // 上传地址,根据项目获取
def ASSETS_END_POINT_PARAM // Assets endPoint根据项目获取
2025-05-08 16:21:32 +08:00
2024-09-24 17:39:15 +08:00
// 构建地址
def BUILD_PATH
2024-09-24 17:39:15 +08:00
// 日志地址
def log_path
2024-09-24 17:39:15 +08:00
def GetRemote(){
if('VinnyTest' == params.Channel)
2025-12-23 12:06:52 +08:00
return 'feature/VinnyTest';
2025-10-15 16:50:30 +08:00
if('Zhanhui' == params.Channel)
return 'zhanhui';
2025-10-20 16:34:03 +08:00
if('Dev' == params.Channel)
2025-12-23 12:06:52 +08:00
return 'dev';
if('QA_Dev' == params.Channel)
2025-12-23 12:06:52 +08:00
return 'qa_dev';
2025-10-20 16:34:03 +08:00
else
return params.Channel;
}
def CheckRemoteBranchExists(repoUrl, branchName) {
def result = sh(
script: "git ls-remote --heads ${repoUrl} refs/heads/${branchName}",
returnStdout: true
).trim()
if (result == '') {
echo "警告: 远程分支 ${branchName} 不存在于 ${repoUrl}"
return false
}
echo "远程分支 ${branchName} 存在"
return true
2024-11-06 15:58:17 +08:00
}
2024-09-24 17:39:15 +08:00
def SendMessageToWechat(message){
2024-10-09 17:13:54 +08:00
if (!message) {
return }
2024-09-24 17:39:15 +08:00
def INNER_ROBOT="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=3c92758c-1128-4931-ac8d-f19669d7befe"
sh "chmod +x $WORKSPACE/Tool/build_tools/send_wechat_message.sh"
sh "$WORKSPACE/Tool/build_tools/send_wechat_message.sh '${INNER_ROBOT}' '@all' '${message}'"
}
2024-09-27 16:51:57 +08:00
def ParseBuildLogError(logPath){
sh "chmod +x $WORKSPACE/Tool/build_tools/parse_unity_build_log.sh"
2024-11-06 15:58:17 +08:00
// 转译 "\[Build Exception\]:" 取消使用
// def exceptionFlag = '\\[Build Exception\\]:'
2024-11-05 12:53:25 +08:00
def errorMessage = sh(script: "${WORKSPACE}/Tool/build_tools/parse_unity_build_log.sh ${logPath} 'error CS' true true", returnStdout: true).trim()
2024-11-06 15:58:17 +08:00
def exceptionMessage = sh(script: "${WORKSPACE}/Tool/build_tools/parse_unity_build_log.sh ${logPath} 'Build Exception' false true", returnStdout: true).trim()
2024-09-27 16:51:57 +08:00
def sceneMessage = sh(script: "${WORKSPACE}/Tool/build_tools/parse_unity_build_log.sh ${logPath} 'Problem detected while' true true", returnStdout: true).trim()
2024-10-09 17:13:54 +08:00
def multipleMessage = sh(script: "${WORKSPACE}/Tool/build_tools/parse_unity_build_log.sh ${logPath} 'Multiple Unity' true false", returnStdout: true).trim()
2024-10-15 19:44:22 +08:00
def processSceneMessage = sh(script: "${WORKSPACE}/Tool/build_tools/parse_unity_build_log.sh ${logPath} 'Failed to process scene' true false", returnStdout: true).trim()
2024-10-09 17:13:54 +08:00
2024-09-27 16:51:57 +08:00
SendMessageToWechat(errorMessage)
SendMessageToWechat(exceptionMessage)
SendMessageToWechat(sceneMessage)
2024-10-09 17:13:54 +08:00
SendMessageToWechat(multipleMessage)
2024-10-15 19:44:22 +08:00
SendMessageToWechat(processSceneMessage)
2024-09-27 16:51:57 +08:00
}
2024-09-24 17:39:15 +08:00
pipeline {
agent any
stages {
stage('拉最新工程') {
steps {
script {
try {
def currentPath = sh(script: 'pwd', returnStdout: true).trim()
echo "cd ${currentPath}"
2025-05-08 16:21:32 +08:00
// 1. 还原子模块修改
def gitDirExists = sh(script: '[ -d ".git" ] && echo "true" || echo "false"', returnStdout: true).trim()
def scriptPathExists = fileExists("${WORKSPACE}/Tool/build_tools/git_revert_modules_modification.sh")
if (gitDirExists == 'true' && scriptPathExists) {
sh "chmod +x $WORKSPACE/Tool/build_tools/git_revert_modules_modification.sh"
sh "$WORKSPACE/Tool/build_tools/git_revert_modules_modification.sh $WORKSPACE"
}
2025-05-08 16:21:32 +08:00
// 2. 拉取主项目代码
2025-10-20 16:34:03 +08:00
def repoUrl = 'http://1.14.122.170:3000/PHXH/NLDClient.git'
def remote = GetRemote();
2025-10-20 16:34:03 +08:00
echo "获取到分支名字:${remote}"
// 检查远程分支是否存在
if (!CheckRemoteBranchExists(repoUrl, remote)) {
2025-12-23 19:44:55 +08:00
def message = "【${PLATFORM_PARAM}】【${VERSION_PARAM}】【Debug】【${CHANNEL_PARAM}】远程分支 ${remote} 不存在,使用默认分支 dev"
2025-10-20 16:34:03 +08:00
SendMessageToWechat(message)
2025-12-23 12:06:52 +08:00
remote = 'dev' // 回退到默认分支
2025-10-20 16:34:03 +08:00
}
echo "拉取分支:${remote}"
checkout scmGit(
branches: [[name: "*/${remote}"]],
extensions: [
checkoutOption(60),
lfs(),
cloneOption(noTags: false, reference: '', shallow: false, timeout: 120),
submodule(recursiveSubmodules: true, reference: '', timeout: 1200)
],
2025-10-20 16:34:03 +08:00
userRemoteConfigs: [[url: repoUrl]]
)
2025-05-08 16:21:32 +08:00
// 3. 删除旧 GamePlay_Dll 文件夹
def gameplayDllPath = "${WORKSPACE}/ProjectNLD/Assets/Code/Scripts/GamePlay_Dll"
sh "if [ -d '${gameplayDllPath}' ]; then rm -rf '${gameplayDllPath}'; fi"
2025-05-08 16:21:32 +08:00
// 4. 拉取 GamePlay 仓库
def gameplayTargetPath = "${WORKSPACE}/ProjectNLD/Assets/Code/Scripts/GamePlay"
2025-10-20 16:34:03 +08:00
def gameplayUrl = "http://1.14.122.170:3000/PHXH/GamePlay.git"
def branch = GetRemote();
2025-10-20 16:34:03 +08:00
// 检查远程分支是否存在
if (!CheckRemoteBranchExists(gameplayUrl, branch)) {
2025-12-23 19:44:55 +08:00
def message = "【${PLATFORM_PARAM}】【${VERSION_PARAM}】【Debug】【${CHANNEL_PARAM}】远程分支 ${branch} 不存在,使用默认分支 dev"
2025-10-20 16:34:03 +08:00
SendMessageToWechat(message)
2025-12-23 19:44:55 +08:00
branch = 'dev' // 回退到默认分支
2025-10-20 16:34:03 +08:00
}
sh "chmod +x ${WORKSPACE}/Tool/build_tools/git_pull_gameplay.sh"
2025-10-20 16:34:03 +08:00
sh "$WORKSPACE/Tool/build_tools/git_pull_gameplay.sh ${gameplayTargetPath} ${gameplayUrl} ${branch}"
} catch (err) {
def message = "【${PLATFORM_PARAM}】【${VERSION_PARAM}】【Debug】【${CHANNEL_PARAM}】拉最新工程失败"
SendMessageToWechat(message)
error("Failure of the '拉最新工程' stage")
}
}
2024-09-24 17:39:15 +08:00
}
}
stage('获取项目配置') {
steps {
script {
try {
// 将项目相关配置复制到打包路径下
sh "chmod +x $WORKSPACE/Tool/build_tools/copy_env.sh"
sh "$WORKSPACE/Tool/build_tools/copy_env.sh $WORKSPACE/Tool/build_env"
2024-09-24 17:39:15 +08:00
// 将打包机器相关配置复制到打包路径下
echo "copy local env file to $WORKSPACE"
sh "cp /Users/mayuanzheng/Builds/local_env.sh $WORKSPACE/Tool/build_tools/"
} catch (err) {
def message = "【${PLATFORM_PARAM}】【${VERSION_PARAM}】【Debug】【${CHANNEL_PARAM}】获取项目配置失败"
SendMessageToWechat(message)
error("Failure of the '获取项目配置' stage")
}
}
2024-09-24 17:39:15 +08:00
}
}
2025-07-25 14:54:48 +08:00
stage('修改渠道文件夹') {
steps {
script {
try {
2025-07-25 15:54:42 +08:00
// 先安装pyyaml
sh "pip3 install pyyaml --user"
2025-07-25 14:54:48 +08:00
// 调用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}】【Debug】【${CHANNEL_PARAM}】修改渠道文件夹失败: pythonResult=${pythonResult}"
SendMessageToWechat(message)
error("Failure of the '修改渠道文件夹' stage")
}
} catch (err) {
def message = "【${PLATFORM_PARAM}】【${VERSION_PARAM}】【Debug】【${CHANNEL_PARAM}】根据渠道修改工程失败"
SendMessageToWechat(message)
error("Failure of the '修改渠道文件夹' stage")
}
}
}
}
2024-09-24 17:39:15 +08:00
stage('根据渠道修改工程') {
steps {
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}】【Debug】【${CHANNEL_PARAM}】根据渠道修改工程失败"
SendMessageToWechat(message)
error("Failure of the '根据渠道修改工程' stage")
}
}
2024-09-24 17:39:15 +08:00
}
}
2025-05-08 16:21:32 +08:00
stage('根据渠道获取相关参数') {
steps {
script {
try {
echo "根据 [${params.Channel}] 渠道获取相关参数"
2025-06-24 13:11:47 +08:00
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}】【Debug】【${CHANNEL_PARAM}】根据渠道获取相关参数失败"
SendMessageToWechat(message)
error("Failure of the '根据渠道获取相关参数' stage")
}
}
}
}
2024-09-24 17:39:15 +08:00
stage('打包') {
steps {
sh "chmod +x $WORKSPACE/Tool/build_tools/build_unity.sh"
sh "chmod +x $WORKSPACE/Tool/build_tools/hot_update.sh"
script {
def build_result
if(params.Debug_AllLocal == true)
PROFILE_PARAM="AllLocal"
if(params.Build_InitApp == false){
build_result=sh(script: "$WORKSPACE/Tool/build_tools/hot_update.sh ${VERSION_PARAM} ${PLATFORM_PARAM} ${PROFILE_PARAM} ${CHANNEL_PARAM} ${HOTUPDATE_PARAM} ${DEBUGBUILD_PARAM} ${ANDROIDKEYSTORE} ${ANDROIDKEYALIAS} ${OBFUZ}", returnStatus: true, returnStdout: false)
2024-09-24 17:39:15 +08:00
log_path="$BUILD_PATH/UpdatePreviousBuild.log"
}
else
build_result=sh(script: "$WORKSPACE/Tool/build_tools/build_unity.sh ${VERSION_PARAM} ${PLATFORM_PARAM} ${PROFILE_PARAM} ${CHANNEL_PARAM} ${HOTUPDATE_PARAM} ${DEBUGBUILD_PARAM} ${AAB_PARAM} ${DEV_PARAM} ${ANDROIDKEYSTORE} ${ANDROIDKEYALIAS} ${OBFUZ} ${UPLOAD_SYMBOL}", returnStatus: true, returnStdout: false)
2024-09-24 17:39:15 +08:00
2025-08-22 17:32:42 +08:00
def parse_log = "../../$log_path"
2024-09-24 17:39:15 +08:00
// 打包失败
if(build_result != 0)
{
2024-09-27 16:51:57 +08:00
// 归档并分析日志
2024-09-24 17:39:15 +08:00
archiveArtifacts artifacts: "$log_path" , followSymlinks: false
2024-09-27 16:51:57 +08:00
ParseBuildLogError(parse_log)
2024-09-24 17:39:15 +08:00
2024-09-26 16:51:33 +08:00
def message = "【${PLATFORM_PARAM}】【${VERSION_PARAM}】【Debug】【${CHANNEL_PARAM}】构建失败"
2024-09-24 17:39:15 +08:00
SendMessageToWechat(message)
error("Failure of the '打包' stage")
}
2025-08-22 17:32:42 +08:00
// 保底捕捉一次 Build Finished, Result: Failure.
else{
sh "chmod +x $WORKSPACE/Tool/build_tools/check_unity_build_result.sh"
2025-08-22 18:06:29 +08:00
def check_result = sh(script: "sh $WORKSPACE/Tool/build_tools/check_unity_build_result.sh ${parse_log}", returnStatus: true)
2025-08-22 17:32:42 +08:00
if (check_result != 0) {
// 归档日志
archiveArtifacts artifacts: "$log_path" , followSymlinks: false
2025-08-22 17:32:42 +08:00
def message = "【${PLATFORM_PARAM}】【${VERSION_PARAM}】【Debug】【${CHANNEL_PARAM}】构建失败 日志捕捉到 Build Finished, Result: Failure."
SendMessageToWechat(message)
error("Failure of the '打包' stage")
}
}
2024-09-24 17:39:15 +08:00
}
}
}
2025-12-22 16:21:27 +08:00
stage('加密应用') {
steps {
script {
if (PACKAGE_HARDENING == true) {
2025-12-22 16:21:27 +08:00
// 只在构建完整应用时进行加密
2025-12-23 12:06:52 +08:00
echo "params.Build_InitApp: ${params.Build_InitApp}"
echo "WORKSPACE: ${WORKSPACE}"
2025-12-22 16:21:27 +08:00
if (params.Build_InitApp == true) {
try {
2025-12-23 12:06:52 +08:00
// 确保CHANNEL_PARAM是正确的渠道名称
def actualChannel = CHANNEL_PARAM ?: "Dev"
echo "Actual channel: ${actualChannel}"
// 构建YAML文件路径添加备选路径
def playersettings = "${WORKSPACE}/Tool/Channels/${actualChannel}/ChannelSetting.yaml"
def fallbackPlayersettings = "d:/UnityProjects/NLDClient/Tool/Channels/${actualChannel}/ChannelSetting.yaml"
// 选择存在的YAML文件路径
def finalPlayersettings
if (fileExists(playersettings)) {
finalPlayersettings = playersettings
} else if (fileExists(fallbackPlayersettings)) {
finalPlayersettings = fallbackPlayersettings
} else {
echo "Warning: Both YAML paths not found. Using default: ${playersettings}"
finalPlayersettings = playersettings
}
// 添加调试信息
echo "playersettings path: ${finalPlayersettings}"
echo "File exists: ${fileExists(finalPlayersettings)}"
// 读取YAML文件添加错误处理
def cfg
try {
cfg = readYaml(file: finalPlayersettings)
echo "YAML content: ${cfg}"
} catch (yamlErr) {
echo "Error reading YAML: ${yamlErr.getMessage()}"
// 尝试使用另一种方式读取YAML
def yamlContent = readFile(finalPlayersettings)
echo "Raw YAML content: ${yamlContent}"
error "Failed to parse YAML file"
}
2025-12-22 16:21:27 +08:00
// 读取加密相关配置
def encryptConfig = cfg?.Encryption
2025-12-23 12:06:52 +08:00
echo "encryptConfig: ${encryptConfig}"
2025-12-22 16:21:27 +08:00
if (encryptConfig) {
def apiUrl = (encryptConfig?.ApiUrl ?: '').trim()
def strategyName = (encryptConfig?.StrategyName ?: '').trim()
def username = (encryptConfig?.Username ?: '').trim()
def password = (encryptConfig?.Password ?: '').trim()
def toolPath = (encryptConfig?.ToolPath ?: '').trim()
def needSign = (encryptConfig?.NeedSign ?: true)
def signName = (encryptConfig?.SignName ?: '').trim()
def signVersion = (encryptConfig?.SignVersion ?: 4)
def retryCount = (encryptConfig?.RetryCount ?: 3)
// 构建APK路径
def apkPath = "$WORKSPACE/Builds/$CHANNEL_PARAM/$PLATFORM_PARAM/$VERSION_PARAM/$APK_NAME"
def outputDir = "$WORKSPACE/Builds/$CHANNEL_PARAM/$PLATFORM_PARAM/$VERSION_PARAM"
// 替换WORKSPACE变量
toolPath = toolPath.replace('${WORKSPACE}', WORKSPACE)
// 构建加密命令
def encryptCmd = "java -jar '${toolPath}' -t apk -u '${apiUrl}' -r '${username}' -w '${password}' -k '${apkPath}' -s '${strategyName}' -d '${outputDir}' -n '${APK_NAME}' -y ${retryCount}"
// 添加签名参数
if (needSign) {
encryptCmd += " -i true -g '${signName}' -v ${signVersion}"
}
echo "开始加密应用..."
echo "APK路径: ${apkPath}"
echo "加密策略: ${strategyName}"
echo "执行命令: ${encryptCmd}"
// 执行加密命令
def encryptResult = sh(script: encryptCmd, returnStatus: true, returnStdout: false)
if (encryptResult != 0) {
def message = "【${PLATFORM_PARAM}】【${VERSION_PARAM}】【Debug】【${CHANNEL_PARAM}】应用加密失败"
SendMessageToWechat(message)
error("Failure of the '加密应用' stage")
} else {
echo "应用加密成功加密后的APK已覆盖原APK。"
}
} else {
echo "警告:未在渠道配置中找到加密相关配置,跳过加密步骤。"
}
} catch (err) {
def message = "【${PLATFORM_PARAM}】【${VERSION_PARAM}】【Debug】【${CHANNEL_PARAM}】应用加密过程中发生异常: ${err.getMessage()}"
SendMessageToWechat(message)
error("Failure of the '加密应用' stage")
}
} else {
echo "增量更新模式,跳过加密步骤。"
}
} else {
echo "PackageHardening 未启用,跳过加密步骤。"
}
2025-12-22 16:21:27 +08:00
}
}
}
2024-09-24 17:39:15 +08:00
stage('上传资源') {
steps {
script {
def asset_path="$WORKSPACE/ProjectNLD/ServerData/${PLATFORM_PARAM}"
2025-06-04 14:09:30 +08:00
def upload_path="${OSS_UPLOAD_PATH_PARAM}/${CHANNEL_PARAM}/${PLATFORM_PARAM}/${VERSION_PARAM}"
2025-10-28 15:25:33 +08:00
if(params.Upload_Incremental == true)
2024-09-24 17:39:15 +08:00
{
2025-10-28 15:25:33 +08:00
def upload_incremental_result=0
def last_manifest_path="$WORKSPACE/ProjectNLD/ServerData/LastManifests/${CHANNEL_PARAM}"
2025-10-28 15:25:33 +08:00
sh "chmod +x $WORKSPACE/Tool/build_tools/upload_incremental_oss.sh"
upload_incremental_result = sh(script: "$WORKSPACE/Tool/build_tools/upload_incremental_oss.sh ${asset_path} ${upload_path} ${ASSETS_END_POINT_PARAM} ${last_manifest_path}", returnStatus: true, returnStdout: false)
if(upload_incremental_result != 0)
{
def message = "【${PLATFORM_PARAM}】【${VERSION_PARAM}】【Debug】【${CHANNEL_PARAM}】上传资源失败"
SendMessageToWechat(message)
error("Failure of the '上传资源' stage")
}
}
else
{
sh "chmod +x $WORKSPACE/Tool/build_tools/upload_oss.sh"
def upload_result=0
upload_result = sh(script: "$WORKSPACE/Tool/build_tools/upload_oss.sh ${asset_path} ${upload_path} ${ASSETS_END_POINT_PARAM}", returnStatus: true, returnStdout: false)
if(upload_result != 0)
{
def message = "【${PLATFORM_PARAM}】【${VERSION_PARAM}】【Debug】【${CHANNEL_PARAM}】上传资源失败"
SendMessageToWechat(message)
error("Failure of the '上传资源' stage")
}
2024-09-24 17:39:15 +08:00
}
2025-10-28 15:25:33 +08:00
2024-09-24 17:39:15 +08:00
}
}
}
2025-12-17 16:49:39 +08:00
/*stage('上传apk') {
2024-09-24 17:39:15 +08:00
steps {
script {
// 增量更新不需要上传包体
if (params.Build_InitApp == true){
2024-10-16 13:40:29 +08:00
def apk_path="$WORKSPACE/Builds/$CHANNEL_PARAM/$PLATFORM_PARAM/$VERSION_PARAM/$APK_NAME"
2025-06-04 14:09:30 +08:00
def upload_path="${OSS_UPLOAD_PATH_PARAM}/${CHANNEL_PARAM}/${PLATFORM_PARAM}/"
def upload_path_with_version="${OSS_UPLOAD_PATH_PARAM}/${CHANNEL_PARAM}/${PLATFORM_PARAM}/${VERSION_PARAM}/"
def upload_result=0
def upload_result_with_version=0
2025-05-08 16:21:32 +08:00
2025-06-04 14:09:30 +08:00
upload_result=sh(script: "$WORKSPACE/Tool/build_tools/upload_oss.sh ${apk_path} ${upload_path} ${ASSETS_END_POINT_PARAM}", returnStatus: true, returnStdout: false)
upload_result_with_version=sh(script: "$WORKSPACE/Tool/build_tools/upload_oss.sh ${apk_path} ${upload_path_with_version} ${ASSETS_END_POINT_PARAM}", returnStatus: true, returnStdout: false)
2025-05-08 16:21:32 +08:00
if(upload_result != 0 || upload_result_with_version != 0)
2024-09-24 17:39:15 +08:00
{
2024-09-26 16:51:33 +08:00
def message = "【${PLATFORM_PARAM}】【${VERSION_PARAM}】【Debug】【${CHANNEL_PARAM}】上传APK失败"
2024-09-24 17:39:15 +08:00
SendMessageToWechat(message)
error("Failure of the '上传apk' stage")
}
}
}
}
}
2024-09-26 16:51:33 +08:00
stage('上传符号表') {
steps {
script {
2025-10-16 13:27:01 +08:00
if(UPLOAD_SYMBOL == true)
2025-10-15 16:50:30 +08:00
{
// 增量更新不需要上传符号表
sh "chmod +x $WORKSPACE/Tool/build_tools/upload_symbol_file.sh"
sh "chmod +x $WORKSPACE/Tool/build_tools/upload_symbol_file_firebase.sh"
if (params.Build_InitApp == true){
def playersettings = "${WORKSPACE}/Tool/Channels/${CHANNEL_PARAM}/ChannelSetting.yaml"
def cfg = readYaml(file: playersettings)
def symbol_path="$WORKSPACE/Builds/$CHANNEL_PARAM/$PLATFORM_PARAM/$VERSION_PARAM"
def upload_result=0
if('GoogleDev' == params.Channel)
{
def FIREBASE_APP_ID = (cfg?.FIREBASE_APP_ID ?: '').trim()
echo "获取到的Firebase App ID ${FIREBASE_APP_ID}"
upload_result = sh(script: "$WORKSPACE/Tool/build_tools/upload_symbol_file_firebase.sh ${VERSION_PARAM} ${symbol_path} ${FIREBASE_APP_ID}", returnStatus: true, returnStdout: false)
}
else
{
def crashsightConfig = cfg?."CrashSight_${PLATFORM_PARAM}"
def crashsightId = (crashsightConfig?.id ?: '').trim()
def crashsightKey = (crashsightConfig?.key ?: '').trim()
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}】【Debug】【${CHANNEL_PARAM}】上传符号表异常"
SendMessageToWechat(message)
}
}
2024-09-26 16:51:33 +08:00
}
}
}
2025-12-17 16:49:39 +08:00
}*/
2025-06-17 15:42:12 +08:00
stage('发布debug版本号') {
steps {
script {
2025-06-20 14:10:37 +08:00
if (params.Build_InitApp == true){
sh "chmod +x $WORKSPACE/Tool/build_tools/debug_send_version.sh"
def result=0
result = sh(script: "$WORKSPACE/Tool/build_tools/debug_send_version.sh")
}
2025-06-17 15:42:12 +08:00
}
}
}
2024-09-24 17:39:15 +08:00
stage('归档') {
steps {
script {
try{
archiveArtifacts artifacts: "$log_path" , followSymlinks: false
if (params.Build_InitApp == true)
archiveArtifacts artifacts: "$BUILD_PATH/*.apk" , followSymlinks: false
}
catch(Exception e){
SendMessageToWechat(e.message + "\r\n" + e.stackTrace)
currentBuild.result = 'FAILURE'
return
}
}
}
}
stage('通知') {
steps {
script {
if (params.Build_InitApp == true) {
def message = "【${PLATFORM_PARAM}】【${VERSION_PARAM}】【Debug】【${CHANNEL_PARAM}】客户端打包上传成功!下载链接:${ARTIFACT_URL}"
SendMessageToWechat(message)
} else {
def message = "【${PLATFORM_PARAM}】【${VERSION_PARAM}】【Debug】【${CHANNEL_PARAM}】客户端增量更新上传成功!下载链接:${ARTIFACT_URL}"
SendMessageToWechat(message)
}
}
}
}
}
2025-06-17 15:42:12 +08:00
}