为目标安卓release渠道添加加固流程
parent
4926401c53
commit
451f8d4387
|
|
@ -46,3 +46,14 @@ Packages:
|
|||
- CrashSight@latest
|
||||
- TalkingData@0.0.1
|
||||
|
||||
# 爱加密配置
|
||||
Encryption:
|
||||
ApiUrl: "https://runenc.ijiami.cn/common" # 爱加密API地址
|
||||
StrategyName: "Dev加固策略" # 加密策略名称
|
||||
Username: "PHXHJG" # 爱加密用户名
|
||||
Password: "LaMYRIx0UzFgCIR" # 爱加密密码
|
||||
ToolPath: "${WORKSPACE}/Tool/build_tools/encryptionTool-v4.3.6-202409.jar" # 加密工具路径
|
||||
NeedSign: true # 是否需要签名
|
||||
SignName: "朴合辛火安卓" # 签名名称
|
||||
SignVersion: 4 # 签名版本(1-8)
|
||||
RetryCount: 3 # 异常重试次数
|
||||
|
|
|
|||
|
|
@ -26,3 +26,15 @@ Version: "0.1.0"
|
|||
CrashSight_Android:
|
||||
id: "9e1297bfd2" # 崩溃上报的 App ID
|
||||
key: "ffeaeb80-b215-4e27-b647-0ff8c6aac5e1" # 崩溃上报的 Key
|
||||
|
||||
# 爱加密配置
|
||||
Encryption:
|
||||
ApiUrl: "https://runenc.ijiami.cn/common" # 爱加密API地址
|
||||
StrategyName: "Dev加固策略" # 加密策略名称
|
||||
Username: "PHXHJG" # 爱加密用户名
|
||||
Password: "LaMYRIx0UzFgCIR" # 爱加密密码
|
||||
ToolPath: "${WORKSPACE}/Tool/build_tools/encryptionTool-v4.3.6-202409.jar" # 加密工具路径
|
||||
NeedSign: true # 是否需要签名
|
||||
SignName: "朴合辛火安卓" # 签名名称
|
||||
SignVersion: 4 # 签名版本(1-8)
|
||||
RetryCount: 3 # 异常重试次数
|
||||
|
|
|
|||
|
|
@ -55,11 +55,11 @@ def GetRemote(){
|
|||
if('Banshu' == params.Channel)
|
||||
return 'shenhe';
|
||||
else if('Official' == params.Channel)
|
||||
return 'main'
|
||||
return 'dev'
|
||||
else if('TapTap' == params.Channel)
|
||||
return 'tap_release'
|
||||
else if('ReleaseTest' == params.Channel)
|
||||
return 'main'
|
||||
return 'dev'
|
||||
else if('Test' == params.Channel)
|
||||
return 'test'
|
||||
else if('Bilibili' == params.Channel)
|
||||
|
|
@ -235,6 +235,108 @@ pipeline {
|
|||
}
|
||||
}
|
||||
}
|
||||
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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue