Jenkins参数化构建过程中参数的传递
设置完参数化构建过程后的面板如下:将参数传递到Python脚本中:P4_Version = os.environ["P4_Version"];#P4版本号P4_Version = P4_Version.strip();DevelopmentBuild = os.environ["DevelopmentBuild"];#DevelopmentBuildDeve
·
设置完参数化构建过程后的面板如下:
将参数传递到Python脚本中:
P4_Version = os.environ["P4_Version"]; #P4版本号
P4_Version = P4_Version.strip();
DevelopmentBuild = os.environ["DevelopmentBuild"]; #DevelopmentBuild
DevelopmentBuild = DevelopmentBuild.strip();
Unity_Version = os.environ["Unity_Version"]; #Unity的Build Setting版本号
Unity_Version = Unity_Version.strip();
Bundle_Version_Code = os.environ["Bundle_Version_Code"]; #Unity中Build Setting的Bundle Version Code
Bundle_Version_Code = Bundle_Version_Code.strip();
Scripting_Define_Symbols = os.environ["Scripting_Define_Symbols"]; #Unity中的宏定义
Scripting_Define_Symbols = Scripting_Define_Symbols.strip();
P4_Path = os.environ["P4_Path"]; #分支或主支的服务器路径,格式如上(默认为主支路径)
P4_Path = P4_Path.strip();
def GetEnviromentParam():
print(P4_Version);
print(DevelopmentBuild);
print(Unity_Version);
print(Bundle_Version_Code);
print(Scripting_Define_Symbols);
print(P4_Path);
print("获取环境化参数完成!~");
将参数传递到Unity中:
Python脚本中执行以下代码:
def AutoPack():
cmdLine = "";
cmdLine += "cd/d D:\Program Files\Unity5.3.4p4\Editor\n";
cmdLine += "Unity.exe -batchMode -projectPath " + localClientPath + " -executeMethod AndroidAutoVersionTool.MyMethod -quit ";
cmdLine += DevelopmentBuild + " ";
cmdLine += Unity_Version + " ";
cmdLine += Bundle_Version_Code + " ";
cmdLine += Scripting_Define_Symbols;
print(cmdLine);
cmdPath = "G:/Key_doc.bat";
fdoc = open(cmdPath, "w");
fdoc.write(cmdLine);
fdoc.close();
print("命令行文件生成完成!~");
ExecuteCmd(cmdPath);
print("OK!~");
Unity中执行以下代码,获取对应的参数:
static void MyMethod()
{
SwitchToAndroidPlatform();
commandList.Clear();
Caching.CleanCache();
foreach(string arg in System.Environment.GetCommandLineArgs())
{
commandList.Add(arg);
}
bool DevelopmentBuild = false;
string Unity_Version = "";
int Bundle_Version_Code = 101;
string Scripting_Define_Symbols = "";
DevelopmentBuild = bool.Parse(commandList[commandList.Count - 4]);
Unity_Version = commandList[commandList.Count - 3].ToString();
Bundle_Version_Code = int.Parse(commandList[commandList.Count - 2]);
Scripting_Define_Symbols = commandList[commandList.Count - 1].ToString();
Scripting_Define_Symbols = Scripting_Define_Symbols.Replace(',', ';');
}
更多推荐
已为社区贡献4条内容
所有评论(0)