移除不需要的shell脚本

main
Yurui 2025-12-23 19:46:54 +08:00
parent 519d5fb756
commit 5afbe336f4
1 changed files with 0 additions and 439 deletions

View File

@ -1,439 +0,0 @@
// 线
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
def DEV_PARAM = IsDev()
def ANDROIDKEYSTORE = "/Users/mayuanzheng/key/phxh_android.keystore"
def ANDROIDKEYALIAS = "avery"
def UPLOAD_SYMBOL = true
// Jenkins
def ARTIFACT_URL = "http://${env.PHXH_BUILDER_IP_ADDRESS}:8080/job/${env.JOB_NAME}/"
def VERSION_PARAM //
def OSS_UPLOAD_PATH_PARAM //
def ASSETS_END_POINT_PARAM // Assets endPoint
//
def BUILD_PATH
//
def log_path
def SendMessageToWechat(message){
if (!message) {
return }
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}'"
}
def ParseBuildLogError(logPath){
sh "chmod +x $WORKSPACE/Tool/build_tools/parse_unity_build_log.sh"
// "\[Build Exception\]:" 使
// def exceptionFlag = '\\[Build Exception\\]:'
def errorMessage = sh(script: "${WORKSPACE}/Tool/build_tools/parse_unity_build_log.sh ${logPath} 'error CS' true true", returnStdout: true).trim()
def exceptionMessage = sh(script: "${WORKSPACE}/Tool/build_tools/parse_unity_build_log.sh ${logPath} 'Build Exception' false true", returnStdout: true).trim()
def sceneMessage = sh(script: "${WORKSPACE}/Tool/build_tools/parse_unity_build_log.sh ${logPath} 'Problem detected while' true true", returnStdout: true).trim()
def multipleMessage = sh(script: "${WORKSPACE}/Tool/build_tools/parse_unity_build_log.sh ${logPath} 'Multiple Unity' true false", returnStdout: true).trim()
def processSceneMessage = sh(script: "${WORKSPACE}/Tool/build_tools/parse_unity_build_log.sh ${logPath} 'Failed to process scene' true false", returnStdout: true).trim()
SendMessageToWechat(errorMessage)
SendMessageToWechat(exceptionMessage)
SendMessageToWechat(sceneMessage)
SendMessageToWechat(multipleMessage)
SendMessageToWechat(processSceneMessage)
}
def GetRemote(){
if('Banshu' == params.Channel)
return 'shenhe';
else if('Official' == params.Channel)
return 'dev'
else if('TapTap' == params.Channel)
return 'tap_release'
else if('ReleaseTest' == params.Channel)
return 'dev'
else if('Test' == params.Channel)
return 'test'
else if('Bilibili' == params.Channel)
return 'bilibili_release'
else
return 'stable_dev';
}
def IsDev() {
if('Banshu' == params.Channel)
return true;
else if('ReleaseTest' == params.Channel)
return true;
else if('StableDev' == params.Channel)
return true;
else if('Test' == params.Channel)
return true;
else
return false;
}
pipeline {
agent any
stages {
stage('拉最新工程') {
steps {
script {
def currentPath = sh(script: 'pwd', returnStdout: true).trim()
echo "cd ${currentPath}"
// 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"
}
// 2.
def remote = GetRemote();
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)
],
userRemoteConfigs: [[url: 'http://1.14.122.170:3000/PHXH/NLDClient.git']]
)
// 3. GamePlay_Dll
def gameplayDllPath = "${WORKSPACE}/ProjectNLD/Assets/Code/Scripts/GamePlay_Dll"
sh "if [ -d '${gameplayDllPath}' ]; then rm -rf '${gameplayDllPath}'; fi"
// 4. GamePlay
def gameplayTargetPath = "${WORKSPACE}/ProjectNLD/Assets/Code/Scripts/GamePlay"
def gameplayPath = "http://1.14.122.170:3000/PHXH/GamePlay.git"
def branch = GetRemote();
sh "chmod +x ${WORKSPACE}/Tool/build_tools/git_pull_gameplay.sh"
sh "$WORKSPACE/Tool/build_tools/git_pull_gameplay.sh ${gameplayTargetPath} ${gameplayPath} ${branch}"
}
}
}
stage('获取项目配置') {
steps {
//
sh "chmod +x $WORKSPACE/Tool/build_tools/copy_env.sh"
sh "$WORKSPACE/Tool/build_tools/copy_env.sh $WORKSPACE/Tool/build_env"
//
echo "copy local env file to $WORKSPACE"
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 {
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 {
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")
}
}
}
}
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}", returnStatus: true, returnStdout: false)
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} ${UPLOAD_SYMBOL}", returnStatus: true, returnStdout: false)
//
if(build_result != 0)
{
//
archiveArtifacts artifacts: "$log_path" , followSymlinks: false
def parse_log = "../../$log_path"
ParseBuildLogError(parse_log)
def message = "【${PLATFORM_PARAM}】【${VERSION_PARAM}】【Release】【${CHANNEL_PARAM}】构建失败"
SendMessageToWechat(message)
error("Failure of the '打包' stage")
}
}
}
}
stage('加密应用') {
steps {
script {
//
echo "params.Build_InitApp: ${params.Build_InitApp}"
echo "WORKSPACE: ${WORKSPACE}"
if (params.Build_InitApp == true) {
try {
// 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"
}
//
def encryptConfig = cfg?.Encryption
echo "encryptConfig: ${encryptConfig}"
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 "增量更新模式,跳过加密步骤。"
}
}
}
}
stage('上传资源') {
steps {
script {
sh "chmod +x $WORKSPACE/Tool/build_tools/upload_oss.sh"
def asset_path="$WORKSPACE/ProjectNLD/ServerData/${PLATFORM_PARAM}"
def upload_path="${OSS_UPLOAD_PATH_PARAM}/${CHANNEL_PARAM}/${PLATFORM_PARAM}/${VERSION_PARAM}"
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}】【Release】【${CHANNEL_PARAM}】上传资源失败"
SendMessageToWechat(message)
error("Failure of the '上传资源' stage")
}
}
}
}
/*stage('上传apk') {
steps {
script {
//
if (params.Build_InitApp == true){
def apk_path="$WORKSPACE/Builds/$CHANNEL_PARAM/$PLATFORM_PARAM/$VERSION_PARAM/$APK_NAME"
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
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)
if(upload_result != 0 || upload_result_with_version != 0)
{
def message = "【${PLATFORM_PARAM}】【${VERSION_PARAM}】【Release】【${CHANNEL_PARAM}】上传APK失败"
SendMessageToWechat(message)
error("Failure of the '上传apk' stage")
}
}
}
}
}
stage('上传符号表') {
steps {
script {
if(UPLOAD_SYMBOL == true)
{
//
sh "chmod +x $WORKSPACE/Tool/build_tools/upload_symbol_file.sh"
if (params.Build_InitApp == true){
def playersettings = "${WORKSPACE}/Tool/Channels/${CHANNEL_PARAM}/ChannelSetting.yaml"
def symbol_path="$WORKSPACE/Builds/$CHANNEL_PARAM/$PLATFORM_PARAM/$VERSION_PARAM"
def cfg = readYaml(file: playersettings)
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}】上传符号表异常"
SendMessageToWechat(message)
}
}
}
}
}
}*/
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}】【Release】【${CHANNEL_PARAM}】客户端打包上传成功!下载链接:${ARTIFACT_URL}"
SendMessageToWechat(message)
} else {
def message = "【${PLATFORM_PARAM}】【${VERSION_PARAM}】【Release】【${CHANNEL_PARAM}】客户端增量更新上传成功!下载链接:${ARTIFACT_URL}"
SendMessageToWechat(message)
}
}
}
}
}
}