我目前正试图将我的一台Windows 7机器变成一个持续集成服务器,从几个Mercurial存储库构建Unity 3D项目。出于测试目的,我选择了这个相当小的项目,它有一个场景,一个构建脚本,一个.hgignore文件和一堆README.txt文件,所以我可以将文件夹提交到Mercurial。当然,为了这个目的,我在Jenkins中使用Unity3dBuilder,Mercurial和Redmine插件。这是我得到的控制台输出:
$ "C:\Program Files\TortoiseHg\hg.exe" clone --noupdate C:\repo\TemplateUnityProject.hg C:\Bitnami\jenkins-1.568-0\apps\jenkins\jenkins_home\hgcache\F3BC0D0C62E81590DAC468D0CD39E7E3EEF2EA34
Master cache lock released.
$ "C:\Program Files\TortoiseHg\hg.exe" clone --noupdate C:\Bitnami\jenkins-1.568-0\apps\jenkins\jenkins_home\hgcache\F3BC0D0C62E81590DAC468D0CD39E7E3EEF2EA34 "C:\Bitnami\jenkins-1.568-0\apps\jenkins\jenkins_home\jobs\Template Unity Project\workspace"
[workspace] $ "C:\Program Files\TortoiseHg\hg.exe" --config extensions.relink= relink C:\Bitnami\jenkins-1.568-0\apps\jenkins\jenkins_home\hgcache\F3BC0D0C62E81590DAC468D0CD39E7E3EEF2EA34
relinking C:\Bitnami\jenkins-1.568-0\apps\jenkins\jenkins_home\hgcache\F3BC0D0C62E81590DAC468D0CD39E7E3EEF2EA34\.hg/store to C:\Bitnami\jenkins-1.568-0\apps\jenkins\jenkins_home\jobs\Template Unity Project\workspace\.hg/store
tip has 89 files, estimated total number of files: 133
collected 105 candidate storage files
pruned down to 0 probably relinkable files
relinked 0 files (0 bytes reclaimed)
[workspace] $ "C:\Program Files\TortoiseHg\hg.exe" update --rev default
89 files updated, 0 files merged, 0 files removed, 0 files unresolved
[workspace] $ "C:\Program Files\TortoiseHg\hg.exe" log --rev . --template {node}
[workspace] $ "C:\Program Files\TortoiseHg\hg.exe" log --rev . --template {rev}
WARN: Revision data for previous build unavailable; unable to determine change log
Piping unity Editor.log from C:\Windows\system32\config\systemprofile\AppData\Local\Unity\Editor\Editor.log
[workspace] $ "C:\Program Files (x86)\Unity\Editor\Unity.exe" -projectPath "C:\Bitnami\jenkins-1.568-0\apps\jenkins\jenkins_home\jobs\Template Unity Project\workspace" -quiet -bashmode -executeMethod OmiyaGamesBuildScript.BuildAllPlatforms
(many lines later...)
Updating Assets/Prefabs/README.txt - GUID: ccf982a6fa129ff4a8e9531a991ff6e7...
done. [Time: 22.739634 ms]
Updating Assets/Models/README.txt - GUID: e0c2cd9840708ee4aaa37cb896c50e40...
done. [Time: 22.553606 ms]
System memory in use before: 15.4 MB.
Unloading 16 Unused Serialized files (Serialized files now loaded: 0 / Dirty serialized files: 0)
System memory in use after: 13.4 MB.
Unloading 1 unused Assets to reduce memory usage. Loaded Objects now: 292.
Total: 15.136999 ms (FindLiveObjects: 0.071680 ms CreateObjectMapping: 0.017635 ms MarkObjects: 1.146880 ms DeleteObjects: 0.029582 ms)
----- Total AssetImport time: 6.310404s, AssetImport time: 6.069061s, Asset hashing: 0.017528s [9.1 KB, 0.505129 mb/s]
Updating ProjectSettings/GraphicsSettings.asset - GUID: 00000000000000006100000000000000...
done. [Time: 15.341799 ms]
----- Total AssetImport time: 0.076351s, AssetImport time: 0.047076s, Asset hashing: 0.000000s [0 B, 0.000000 mb/s]
Refresh: detecting if any assets need to be imported or removed ... Refresh: elapses 0.005972 seconds (Nothing changed)
Determining assets that need to be reimported for target platform ... 0.021060 seconds.
----- Total AssetImport time: 0.020425s, AssetImport time: 0.000001s, Asset hashing: 0.000000s [0 B, 0.000000 mb/s]
(Then it hangs forever...)
似乎无论出于何种原因,项目在导入每个资产后都会永远挂起。知道为什么会这样吗?
这是使用的构建脚本。它基于Unity3dBuilder plugin示例代码:
using UnityEngine;
using UnityEditor;
using System;
using System.Collections.Generic;
public class OmiyaGamesBuildScript
{
private static readonly string[] AllScenes = FindEnabledEditorScenes();
private const BuildOptions Options = BuildOptions.None;
private const string BuildDirectory = "Builds";
[MenuItem ("Omiya Games/Build All")]
public static void BuildAllPlatforms()
{
PerformWebBuild();
PerformWindows32Build();
PerformWindows64Build();
PerformMac32Build();
PerformMac64Build();
PerformLinux32Build();
PerformLinux64Build();
//PerformIosBuild();
//PerformAndroidBuild();
//PerformWp8Build();
}
[MenuItem ("Omiya Games/Build Web")]
public static void PerformWebBuild()
{
GenericBuild(BuildDirectory + "\\Web\\" + PlayerSettings.productName, BuildTarget.WebPlayer);
}
[MenuItem ("Omiya Games/Build Windows 32")]
public static void PerformWindows32Build()
{
GenericBuild(BuildDirectory + "\\Windows 32-bit\\" + PlayerSettings.productName + ".exe", BuildTarget.StandaloneWindows);
}
[MenuItem ("Omiya Games/Build Windows 64")]
public static void PerformWindows64Build()
{
GenericBuild(BuildDirectory + "\\Windows 64-bit\\" + PlayerSettings.productName + ".exe", BuildTarget.StandaloneWindows64);
}
[MenuItem ("Omiya Games/Build Mac 32")]
public static void PerformMac32Build()
{
GenericBuild(BuildDirectory + "\\Mac 32-bit\\" + PlayerSettings.productName + ".app", BuildTarget.StandaloneOSXIntel);
}
[MenuItem ("Omiya Games/Build Mac 64")]
public static void PerformMac64Build()
{
GenericBuild(BuildDirectory + "\\Mac 64-bit\\" + PlayerSettings.productName + ".app", BuildTarget.StandaloneOSXIntel64);
}
[MenuItem ("Omiya Games/Build Linux 32")]
public static void PerformLinux32Build()
{
GenericBuild(BuildDirectory + "\\Linux 32-bit\\" + PlayerSettings.productName, BuildTarget.StandaloneLinux);
}
[MenuItem ("Omiya Games/Build Linux 64")]
public static void PerformLinux64Build()
{
GenericBuild(BuildDirectory + "\\Linux 64-bit\\" + PlayerSettings.productName, BuildTarget.StandaloneLinux64);
}
[MenuItem ("Omiya Games/Build iOS")]
public static void PerformIosBuild()
{
GenericBuild(BuildDirectory + "\\iOS\\" + PlayerSettings.productName, BuildTarget.iPhone);
}
[MenuItem ("Omiya Games/Build Android")]
public static void PerformAndroidBuild()
{
GenericBuild(BuildDirectory + "\\Android\\" + PlayerSettings.productName, BuildTarget.Android);
}
[MenuItem ("Omiya Games/Build Windows 8")]
public static void PerformWp8Build()
{
GenericBuild(BuildDirectory + "\\Windows 8\\" + PlayerSettings.productName, BuildTarget.WP8Player);
}
private static void GenericBuild(string targetDirectory, BuildTarget buildTarget)
{
EditorUserBuildSettings.SwitchActiveBuildTarget(buildTarget);
string res = BuildPipeline.BuildPlayer(AllScenes, targetDirectory, buildTarget, Options);
if (res.Length > 0)
{
throw new Exception("Failed to build to " + targetDirectory + ":\n" + res);
}
}
private static string[] FindEnabledEditorScenes()
{
List<string> EditorScenes = new List<string>();
foreach(EditorBuildSettingsScene scene in EditorBuildSettings.scenes)
{
if (scene.enabled == true)
{
EditorScenes.Add(scene.path);
}
}
return EditorScenes.ToArray();
}
}
项目当前构建设置的屏幕截图:
Jenkins设置的屏幕截图:
答案 0 :(得分:0)
我终于将输出中打印的命令行复制到服务器中,发现我写了一个错字。而不是-bashmode
,我应该使用-batchmode
。完整的Unity参数现在如下所示:
-batchmode -quit -executeMethod OmiyaGamesBuildScript.BuildAllPlatforms
我上面的错误是在Windows机器上运行shell命令,因此我将其切换为批处理命令。