From ba059e9995ac42546a4ec1a64a8e6fcbc889bcf9 Mon Sep 17 00:00:00 2001 From: huyufei Date: Sun, 31 Mar 2024 22:08:39 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=20JenkinsHelper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Editor/BuildTool/AppBuildParam.cs | 4 +- Editor/BuildTool/JenkinsAgent.cs | 60 -------------- Editor/BuildTool/JenkinsHelper.cs | 81 +++++++++++++++++++ ...insAgent.cs.meta => JenkinsHelper.cs.meta} | 0 4 files changed, 83 insertions(+), 62 deletions(-) delete mode 100644 Editor/BuildTool/JenkinsAgent.cs create mode 100644 Editor/BuildTool/JenkinsHelper.cs rename Editor/BuildTool/{JenkinsAgent.cs.meta => JenkinsHelper.cs.meta} (100%) diff --git a/Editor/BuildTool/AppBuildParam.cs b/Editor/BuildTool/AppBuildParam.cs index 4ed4dbf..aa07bc3 100644 --- a/Editor/BuildTool/AppBuildParam.cs +++ b/Editor/BuildTool/AppBuildParam.cs @@ -15,8 +15,8 @@ namespace Guru.Editor public const string TargetNameIOS = "iOS"; //------------ Basic ---------------- - public bool IsBuildRelease; // 是否构建发布包体 - public bool IsBuildShowLog; // 是否显示日志 + public bool IsBuildRelease = false; // 是否构建发布包体 + public bool IsBuildShowLog = false; // 是否显示日志 public AppBuilderType BuilderType; // 构建类型 public string BuildVersion = ""; // 构建版本号, 填写后会依据此版本设置应用的 Version public bool AutoSetBuildNumber = true; // 自动设置构建号, 可参考 Guru的SDK 接入说明文档 diff --git a/Editor/BuildTool/JenkinsAgent.cs b/Editor/BuildTool/JenkinsAgent.cs deleted file mode 100644 index fac4914..0000000 --- a/Editor/BuildTool/JenkinsAgent.cs +++ /dev/null @@ -1,60 +0,0 @@ - - -namespace Guru.Editor -{ - using System; - using UnityEngine; - - - public class JenkinsAgent - { - - - public static AppBuildParam ParseJenkinsBuildParam(string[] commandlineArgs) - { - int len = commandlineArgs.Length; - - Debug.Log($"------------ Jenkins set commands: {len} ------------"); - - - string p = ""; - for (int i = 0; i < len; i++) - { - p = commandlineArgs[i]; - Debug.Log($"--- [{i}]: {p}"); - - if (p.StartsWith("+args")) - { - Debug.Log($"--- find param: {p}"); - var args = p.Split('-'); - if (args.Length > 1) - { - Debug.Log($"--- ENV: {args[1]}"); - } - if (args.Length > 2) - { - Debug.Log($"--- VERSION: {args[2]}"); - } - } - } - - - var buildParam = new AppBuildParam(); - return buildParam; - } - - - - - public static void BuildAndroid() - { - AppBuildParam buildParam = ParseJenkinsBuildParam(Environment.GetCommandLineArgs()); - } - - - } - - - - -} \ No newline at end of file diff --git a/Editor/BuildTool/JenkinsHelper.cs b/Editor/BuildTool/JenkinsHelper.cs new file mode 100644 index 0000000..d14e6eb --- /dev/null +++ b/Editor/BuildTool/JenkinsHelper.cs @@ -0,0 +1,81 @@ +namespace Guru.Editor +{ + using System; + using UnityEngine; + using System.Linq; + + public class JenkinsHelper + { + public const string DefaultArgsTag = "+args"; + + public static AppBuildParam ParseJenkinsBuildParam(string[] commandlineArgs, string argsTag = "") + { + if (string.IsNullOrEmpty(argsTag)) argsTag = DefaultArgsTag; + int len = commandlineArgs.Length; + + Debug.Log($"------------ Jenkins set commands: {len} ------------"); + + var buildParam = new AppBuildParam() + { + BuilderType = AppBuilderType.Jenkins, + TargetName = "Android", + IsBuildAAB = false, + IsBuildSymbols = false, + AutoPublish = false, + }; + + string p = ""; + for (int i = 0; i < len; i++) + { + p = commandlineArgs[i]; + // Debug.Log($"--- [{i}]: {p}"); + + if (p.StartsWith(argsTag)) + { + // Debug.Log($"--- find param: {p}"); + var args = p.Split('-').ToList(); + if (args.Count > 1) + { + // Debug.Log($"--- ENV: {args[1]}"); + if (args[1].ToUpper() == "RELEASE") + { + buildParam.IsBuildRelease = true; + buildParam.IsBuildShowLog = false; + buildParam.IsBuildSymbols = true; + } + else + { + buildParam.IsBuildRelease = false; + buildParam.IsBuildShowLog = true; + buildParam.IsBuildSymbols = false; + } + } + if (args.Count > 2) + { + // Debug.Log($"--- VERSION: {args[2]}"); + buildParam.BuildVersion = args[2]; + } + } + } + + return buildParam; + } + + + + /// + /// 获取构建参数 + /// + /// + /// + public static AppBuildParam GetBuildParams(string argsTag = "") + { + return ParseJenkinsBuildParam(Environment.GetCommandLineArgs(), argsTag); + } + + } + + + + +} \ No newline at end of file diff --git a/Editor/BuildTool/JenkinsAgent.cs.meta b/Editor/BuildTool/JenkinsHelper.cs.meta similarity index 100% rename from Editor/BuildTool/JenkinsAgent.cs.meta rename to Editor/BuildTool/JenkinsHelper.cs.meta