【打包】优化上传debug key流程

main
刘涛 2026-04-11 14:33:10 +08:00
parent 7eb6ec9af1
commit cef81f8a64
3 changed files with 50 additions and 2 deletions

View File

@ -447,6 +447,54 @@ internal class BatchBuild
HttpHelper.PostAsync(url, body, dicHeadData).Forget();
}
/// <summary>
/// batchmode 下等待 sendVersion 请求完成,并显式退出 Unity避免 Jenkins 长时间挂起。
/// </summary>
public static async void PostDebugSendKeyBatch()
{
const int timeoutSeconds = 30;
try
{
string version = PackDataInst.Inst.localInfo.version;
string tag = HashUtils.MD5(version);
Dictionary<string, string> dicHeadData = PostHeader.PostHeaderInfo(new Dictionary<string, string>
{
{ "plaintext", version },
{ "platform", "0" },
{ "tag", tag },
{ "timestamp", DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString() }
});
SendVersionBody body = new()
{
plaintext = version,
tag = tag,
platform = "0"
};
string url = $"{Dev_PostUrl}sendVersion";
Debug.Log($"[PostDebugSendKeyBatch] Start URL={url}, version={version}, tag(MD5)={tag}, timeout={timeoutSeconds}s");
var result = await HttpHelper.PostAsync(url, body, dicHeadData, timeoutSeconds);
if (result.code != 0)
{
Debug.LogError($"[PostDebugSendKeyBatch] Failed code={result.code}, message={result.message}");
EditorApplication.Exit(1);
return;
}
Debug.Log($"[PostDebugSendKeyBatch] Success message={result.message}");
EditorApplication.Exit(0);
}
catch (Exception e)
{
Debug.LogError($"[PostDebugSendKeyBatch Exception]:{e.Message} \r\n {e.StackTrace}");
EditorApplication.Exit(1);
}
}
#if UNITY_EDITOR
[UnityEditor.MenuItem("Test/Build/测试 Version (version=1.0.0)")]
public static void TestPostDebugSendKey()

@ -1 +1 @@
Subproject commit 6d8d808b9bafe76105897814dbf6891240d0ceb3
Subproject commit e47e2ad436f6ec9d0057e82d76ba9fc1bc314694

@ -1 +1 @@
Subproject commit 3d2d651da6a817280bf674439187f1257e916013
Subproject commit 30d4c15d29e64de4184053eed464170ef75d292b