Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[Resolved] Trouble with Unity 5.4.1f command line on Jenkins

Discussion in 'Formats & External Tools' started by cudreaUdev, Dec 14, 2016.

  1. cudreaUdev

    cudreaUdev

    Joined:
    Dec 14, 2016
    Posts:
    4
    Hi, I'm writing this, hoping someone else has encountered something similar and can help me.

    The gist of it is this: The command line build works if it is run locally but fails when run through Jenkins.
    I'm building iOS and Android versions.

    The setup is a Win7 x64 Jenkins Slave with Unity 5.4.1f installed on it for Android, and an i7 Mac mini with the same version of Unity for iOS.
    On Windows, the same account was used to run the command manually and through Jenkins.

    Both win7 and macos slaves fail with the exact same result: "3 errors".
    I've tried pretty much everything I can think of and I'm really out of ideas.
    Is there any way to see what those 3 errors are ?

    Code (csharp):
    1. DisplayProgressbar: Splitting assets
    2. DisplayProgressbar: Preparing APK resources
    3. DisplayProgressbar: Process plugins
    4. DisplayProgressbar: Processing AAR plugins
    5. DisplayProgressbar: Processing Android libraries
    6. DisplayProgressbar: Creating Android manifest
    7. DisplayProgressbar: Fetching assembly references
    8. DisplayProgressbar: Compiling resources
    9. DisplayProgressbar: Verifying Android libraries
    10. DisplayProgressbar: Building DEX
    11. DisplayProgressbar: Preparing streaming assets
    12. DisplayProgressbar: AAPT: Compiling all assets into one archive
    13. DisplayProgressbar: Creating APK package
    14. DisplayProgressbar: Publishing output package
    15. PostprocessBuild.OnPostprocessBuild(): target=Android pathToBuiltProject=C:/Tools/Jenkins/workspace/PuzzleBuilder-Android/label/Windows_Slave_Unity/Assets/../PuzzleBuilder_Release_iv1.0.771_rev771.apk
    16. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    17. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    18. UnityEngine.Logger:Log(LogType, Object)
    19. UnityEngine.Debug:Log(Object)
    20. PostprocessBuild:OnPostprocessBuild(BuildTarget, String) (at Assets\Scripts\Editor\PostprocessBuild.cs:12)
    21. UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, BuildTarget, BuildOptions, Boolean)
    22. UnityEditor.BuildPipeline:BuildPlayerInternal(String[], String, BuildTarget, BuildOptions) (at C:\buildslave\unity\build\artifacts\generated\common\editor\BuildPipelineBindings.gen.cs:252)
    23. UnityEditor.BuildPipeline:BuildPlayer(String[], String, BuildTarget, BuildOptions) (at C:\buildslave\unity\build\artifacts\generated\common\editor\BuildPipelineBindings.gen.cs:190)
    24. AutomaticBuildScript:GenericBuild(String[], String, BuildTarget, BuildOptions) (at Assets\Scripts\Editor\AutomaticBuildScript.cs:170)
    25. AutomaticBuildScript:PerformAndroidBuild() (at Assets\Scripts\Editor\AutomaticBuildScript.cs:143)
    26. (Filename: Assets/Scripts/Editor/PostprocessBuild.cs Line: 12)
    27.  
    28. DisplayProgressbar: Building Player
    29. Load scene 'Temp/__Backupscenes/0.backup' time: 0.008451 ms
    30. Unloading 197 Unused Serialized files (Serialized files now loaded: 0)
    31. [00:00:00] Enlighten: Reflection Probes took 55.169155 seconds. Cancelled, so not done yet.
    32. System memory in use before: 161.7 MB.
    33. System memory in use after: 163.0 MB.
    34.  
    35. Unloading 216 unused Assets to reduce memory usage. Loaded Objects now: 21296.
    36. Total: 34.736740 ms (FindLiveObjects: 1.191417 ms CreateObjectMapping: 1.410261 ms MarkObjects: 27.156889 ms  DeleteObjects: 4.976363 ms)
    37.  
    38. Unloading 0 Unused Serialized files (Serialized files now loaded: 0)
    39. System memory in use before: 150.5 MB.
    40. System memory in use after: 151.9 MB.
    41.  
    42. Unloading 0 unused Assets to reduce memory usage. Loaded Objects now: 21296.
    43. Total: 28.884096 ms (FindLiveObjects: 1.068864 ms CreateObjectMapping: 0.974686 ms MarkObjects: 26.788929 ms  DeleteObjects: 0.050409 ms)
    44.  
    45. Ignoring 'Assets/FacebookSDK/Plugins/Android/Facebook.Unity.Android.dll' because we're compiling for Editor
    46. Ignoring 'Assets/FacebookSDK/Plugins/Arcade/Facebook.Unity.Arcade.dll' because we're compiling for Editor
    47. Ignoring 'Assets/FacebookSDK/Plugins/Arcade/FacebookNamedPipeClient.dll' because we're compiling for Editor
    48. Ignoring 'C:/Progra~1/Unity/Editor/Data/UnityExtensions/Unity/Advertisements/UnityEngine.Advertisements.dll' because we're compiling for Editor
    49. Ignoring 'C:/Progra~1/Unity/Editor/Data/UnityExtensions/Unity/UnityAnalytics/UnityEngine.Analytics.dll' because we're compiling for Editor
    50. Ignoring 'C:/Progra~1/Unity/Editor/Data/UnityExtensions/Unity/UnityPurchasing/UnityEngine.Purchasing.dll' because we're compiling for Editor
    51. Ignoring 'Assets/FacebookSDK/Plugins/Android/Facebook.Unity.Android.dll' because we're compiling for Editor
    52. Ignoring 'Assets/FacebookSDK/Plugins/Arcade/Facebook.Unity.Arcade.dll' because we're compiling for Editor
    53. Ignoring 'Assets/FacebookSDK/Plugins/Arcade/FacebookNamedPipeClient.dll' because we're compiling for Editor
    54. Ignoring 'C:/Progra~1/Unity/Editor/Data/UnityExtensions/Unity/Advertisements/UnityEngine.Advertisements.dll' because we're compiling for Editor
    55. Ignoring 'C:/Progra~1/Unity/Editor/Data/UnityExtensions/Unity/UnityAnalytics/UnityEngine.Analytics.dll' because we're compiling for Editor
    56. Ignoring 'C:/Progra~1/Unity/Editor/Data/UnityExtensions/Unity/UnityPurchasing/UnityEngine.Purchasing.dll' because we're compiling for Editor
    57. - starting compile Library/ScriptAssemblies/Assembly-CSharp-firstpass.dll, for buildtarget 13
    58. Unloading 6 Unused Serialized files (Serialized files now loaded: 0)
    59. System memory in use before: 150.7 MB.
    60. System memory in use after: 152.1 MB.
    61.  
    62. Unloading 6 unused Assets to reduce memory usage. Loaded Objects now: 21296.
    63. Total: 32.855591 ms (FindLiveObjects: 1.338420 ms CreateObjectMapping: 2.106034 ms MarkObjects: 29.345631 ms  DeleteObjects: 0.063389 ms)
    64.  
    65.  
    66. *** Cancelled 'Build.Player.AndroidPlayer' in 62 seconds (62004 ms)
    67.  
    68. Exception: 3 errors
    69.   at AutomaticBuildScript.GenericBuild (System.String[] scenes, System.String target_dir, BuildTarget build_target, BuildOptions build_options) [0x0001d] in C:\Tools\Jenkins\workspace\PuzzleBuilder-Android\label\Windows_Slave_Unity\Assets\Scripts\Editor\AutomaticBuildScript.cs:173
    70.   at AutomaticBuildScript.PerformAndroidBuild () [0x000d7] in C:\Tools\Jenkins\workspace\PuzzleBuilder-Android\label\Windows_Slave_Unity\Assets\Scripts\Editor\AutomaticBuildScript.cs:143
    71. (Filename: Assets/Scripts/Editor/AutomaticBuildScript.cs Line: 173)
    72.  
    73. executeMethod method AutomaticBuildScript.PerformAndroidBuild threw exception.
    74. (Filename: C:/buildslave/unity/build/Runtime/Utilities/Argv.cpp Line: 171)
    75.  
    76.  
    77. Aborting batchmode due to failure:
    78. executeMethod method AutomaticBuildScript.PerformAndroidBuild threw exception.
    79.  
    80. FATAL: Unity3d command line execution failed with status 1
    81. Build step 'Invoke Unity3d Editor' marked build as failure
    82. CIFS: Current build result is [FAILURE], not going to run.
    83. Finished: FAILURE
     
    Last edited: Dec 15, 2016
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    What is in this line?
    AutomaticBuildScript.PerformAndroidBuild:173

    Also, this doesn't look like the full build log to me... is this all you get from Jenkins?
    If you have access to the build agent, i would connect there and copy the entire editor.log file and examine it (and post it here to help find the issue).
     
  3. cudreaUdev

    cudreaUdev

    Joined:
    Dec 14, 2016
    Posts:
    4
    Sorry I didn't post sooner but I was already at home.

    I have access to the build agent. I ran the build command offline on the same machine.
    I also have the full log, however I have to go over it and make sure it's OK to post.
    What is posted is the relevant part, the log for the successful build is otherwise identical up until the error.

    I'm also quite sure the cause is some sort of remote read or execution permission the JVM lacks because the build command runs fine on the exact same machine. But I don't know exactly what Unity tries to access during the build that would cause this behavior.

    AutomaticBuildScript.PerformAndroidBuild is used in the build command.
    This is the code for AutomaticBuildScript.PerformAndroidBuild:
    Code (CSharp):
    1. static void PerformAndroidBuild()
    2. {
    3.   AndroidSDKFolder.Path = "D:/Tools/AndroidSDK";
    4.  
    5.   Debug.Log("Application.dataPath=" + Application.dataPath);
    6.   Debug.Log("SvnRevision=" + GetCustomArgument("SvnRevision"));
    7.   Debug.Log("Config=" + GetCustomArgument("Config"));
    8.  
    9.   string config = GetCustomArgument("Config");
    10.   string svnrevision = GetCustomArgument("SvnRevision");
    11.   string version = PlayerSettings.bundleVersion;
    12.   if (svnrevision.Length > 0)
    13.   {
    14.     version += "." + svnrevision;
    15.   }
    16.   PlayerSettings.bundleVersion = version;
    17.  
    18.   string apkfilename = "PuzzleBuilder_" + config + "_iv" + version + "_rev" + svnrevision + ".apk";
    19.   string apkname = Application.dataPath + "/../" + apkfilename;
    20.  
    21.   string[] SCENES = FindEnabledEditorScenes();
    22.   GenericBuild(SCENES, apkname, BuildTarget.Android, BuildOptions.None);
    23. }
    and the code for AutomaticBuildScript.GenericBuild:
    Code (CSharp):
    1. static void GenericBuild(string[] scenes, string target_dir, BuildTarget build_target, BuildOptions build_options)
    2. {
    3.   string result = BuildPipeline.BuildPlayer(scenes,target_dir,build_target,build_options);
    4.   EditorUserBuildSettings.SwitchActiveBuildTarget(build_target);
    5.   if (result.Length > 0)
    6.   {
    7.     throw new Exception(result); // <- This is where I get the "3 errors" message
    8.   }
    9. }
     
    Last edited: Dec 15, 2016
  4. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Did you try printing the error message (e.g: the variable 'result') ?
    Could it be that Jenkins is only wired to print STDOUT or something similar and not the STDERR stream ?

    Also, you can use procmon if you're on Windows to determine what the build is doing and what it tries to access.
     
  5. cudreaUdev

    cudreaUdev

    Joined:
    Dec 14, 2016
    Posts:
    4
    Hi liortal,
    Thanks a bunch for the help.
    Pretty much forgot procmon was even a thing anymore (though it ended with WinXP).

    Win7 seems to build android, at least for now.
    In procmon Unity (actually mono.exe) was complaining about being unable to access the "Assembly*.dll" assemblies.
    So I set the owner of the workspace to the Jenkins user alone (it was owned by the group of the Jenkins user) and it started building again.

    Mac also seems to build ios, again, at least for now.
    On mac I had to bump up the Jenkins user to the "admin" group.

    So in the end it's very likely the 3 errors were likely the due to the 3 files: Assembly-CSharp.dll, Assembly-CSharp-Editor.dll and Assembly-CSharp-firstpass.dll. But that's just a hunch based on what I saw.

    Unfortunately the 'result' variable still only said "3 errors" when printed with Debug.Log(result).

    Also to the Unity team, if anyone's reading, hope I'm not being too coy asking, but please add detailed error reporting when using the command line version. "3 errors" is not exactly a very helpful message.
     
    liortal likes this.