How to get batchmode for Linux Editor on Jenkins working

Hey there,

I’m not sure if this is the right sub forum for this question, but I hope so.
I tried last weekend to get a headless Linux server to automatically build my game via Jenkins. While installation of the Linux Editor (Unity 2017.3.0f1 and Unity 2017.3.1f1) was no big deal and I could get a license to import, I’m actually stuck with the error messages I get by the Editor itself.

My call looks like that:

-batchmode -projectPath /var/lib/jenkins/workspace/Elemental War/ElementalWar -executeMethod EW.Builder.BuildWindows -quit -username xxx -password xxx -nographics

The same command (without username and password) works fine on my local Windows machine.

I tried different approaches:

  1. Manually calling command line always results in a segmentation fault. The Editor.log for such a call is attached (Editor.txt)

  2. Invoke the Unity3d plugin for Jenkins: Starting it the first time (or after cleaning the Library folder) processes a lot of stuff (asset reimport, hashing…) and finally fails with some weird error message about the class of my export function (executeMethod) isn’t found. After that every build results with no real error message at all. I attached a log for such a second+ build as Editor2.txt. The only interesting thing there is the error code.

I started another long build with cleared Library folder right now, but it will take a while until I can provide the full log of the build.

I hope someone has some experience with this and can help me with the automation of my builds.

My export script looks like that:

using System.IO;
using UnityEditor;
using UnityEngine;

namespace EW {

    public class Builder : MonoBehaviour {

        private static void Build(BuildTarget target, string folder, string[] scenes) {
            if (!Directory.Exists(Application.dataPath + "/../Export/" + folder + "/")) {
                Directory.CreateDirectory(Application.dataPath + "/../Export/" + folder + "/");
            }

            var buildPlayerOptions = new BuildPlayerOptions {
                scenes = scenes,
                locationPathName = "Export/" + folder + "/Elemental War"
            };

            if (target == BuildTarget.StandaloneWindows64) {
                buildPlayerOptions.locationPathName += ".exe";
            } else if (target == BuildTarget.StandaloneLinux64) {
                buildPlayerOptions.locationPathName += ".x86_64";
            } else if (target == BuildTarget.Android) {
                buildPlayerOptions.locationPathName += ".apk";
            }
            buildPlayerOptions.target = target;
            buildPlayerOptions.options = BuildOptions.None;
            BuildPipeline.BuildPlayer(buildPlayerOptions);
        }

        [MenuItem("Build/Build Android")]
        public static void BuildAndroid() {
            var scenes = new[] { "Assets/Scenes/MainScene.unity", "Assets/Scenes/Mobile.unity", "Assets/Scenes/Grassland1_Mobile.unity", "Assets/Scenes/Iceworld1_Mobile.unity", "Assets/Scenes/Desert1_Mobile.unity", "Assets/Scenes/Forest1_Mobile.unity", "Assets/Scenes/Graveyard1_Mobile.unity", "Assets/Scenes/Swamp1_Mobile.unity" };
            Build(BuildTarget.Android, "Android", scenes);
        }

        [MenuItem("Build/Build iOS")]
        public static void BuildiOs() {
            var scenes = new[] { "Assets/Scenes/MainScene.unity", "Assets/Scenes/Mobile.unity", "Assets/Scenes/Grassland1_Mobile.unity", "Assets/Scenes/Iceworld1_Mobile.unity", "Assets/Scenes/Desert1_Mobile.unity", "Assets/Scenes/Forest1_Mobile.unity", "Assets/Scenes/Graveyard1_Mobile.unity", "Assets/Scenes/Swamp1_Mobile.unity" };
            Build(BuildTarget.iOS, "iOS", scenes);
        }

        [MenuItem("Build/Build UWP")]
        public static void BuildUwp() {
            var scenes = new[] { "Assets/Scenes/MainScene.unity", "Assets/Scenes/Mobile.unity", "Assets/Scenes/Grassland1_Mobile.unity", "Assets/Scenes/Iceworld1_Mobile.unity", "Assets/Scenes/Desert1_Mobile.unity", "Assets/Scenes/Forest1_Mobile.unity", "Assets/Scenes/Graveyard1_Mobile.unity", "Assets/Scenes/Swamp1_Mobile.unity" };
            Build(BuildTarget.WSAPlayer, "UWP", scenes);
        }

        [MenuItem("Build/Build Linux")]
        public static void BuildLinux() {
            var scenes = new[] { "Assets/Scenes/MainScene.unity", "Assets/Scenes/Desktop_Startup.unity", "Assets/Scenes/Desktop.unity", "Assets/Scenes/Grassland1_Desktop.unity", "Assets/Scenes/Iceworld1_Desktop.unity", "Assets/Scenes/Desert1_Desktop.unity", "Assets/Scenes/Forest1_Desktop.unity", "Assets/Scenes/Graveyard1_Desktop.unity", "Assets/Scenes/Swamp1_Desktop.unity" };
            Build(BuildTarget.StandaloneLinux64, "Linux", scenes);
        }

        [MenuItem("Build/Build Mac")]
        public static void BuildOsx() {
            var scenes = new[] { "Assets/Scenes/MainScene.unity", "Assets/Scenes/Desktop_Startup.unity", "Assets/Scenes/Desktop.unity", "Assets/Scenes/Grassland1_Desktop.unity", "Assets/Scenes/Iceworld1_Desktop.unity", "Assets/Scenes/Desert1_Desktop.unity", "Assets/Scenes/Forest1_Desktop.unity", "Assets/Scenes/Graveyard1_Desktop.unity", "Assets/Scenes/Swamp1_Desktop.unity" };
            Build(BuildTarget.StandaloneOSX, "Mac", scenes);
        }

        [MenuItem("Build/Build Windows")]
        public static void BuildWindows() {
            var scenes = new[] { "Assets/Scenes/MainScene.unity", "Assets/Scenes/Desktop_Startup.unity", "Assets/Scenes/Desktop.unity", "Assets/Scenes/Grassland1_Desktop.unity", "Assets/Scenes/Iceworld1_Desktop.unity", "Assets/Scenes/Desert1_Desktop.unity", "Assets/Scenes/Forest1_Desktop.unity", "Assets/Scenes/Graveyard1_Desktop.unity", "Assets/Scenes/Swamp1_Desktop.unity" };
            Build(BuildTarget.StandaloneWindows64, "Windows", scenes);
        }

        [MenuItem("Build/Build All")]
        public static void BuildAll() {
            BuildAndroid();
            //buildiOS();
            //buildUWP();
            //buildLinux();
            //buildOSX();
            BuildWindows();
        }

    }

}

3419034–269671–Editor.txt (2.9 KB)
3419034–269672–Editor2.txt (3.5 KB)

I attached the log of a smaller project. It’s less complex, but has the same error, so I can test faster. What makes me wonder: According to the log the compilation of the Assembly-CSharp files was finished, but they aren’t in the given folder.

-----CompilerOutput:-stdout–exitcode: 255–compilationhadfailure: True–outfile: Temp/Assembly-CSharp-Editor.dll
-----CompilerOutput:-stderr----------
-----EndCompilerOutput---------------

  • Finished compile Library/ScriptAssemblies/Assembly-CSharp-Editor.dll

Library/ScriptAssemblies is empty. Also the first line shows some compilation error has happened, but the output isn’t helpful at all. There must be a reason for that compilation to fail, but I don’t have any idea how I can find it out yet.

3419749–269753–Editor4.txt (41 KB)