Jenkins Unity build exits without and log output

I’m trying to setup Jenkins to build my Unity project but am running into some problems. The editor command line is called successfully but then waits for about 1min30sec and exits with a code of 1. I’m sure that the environment variable is real since I use it to call the editor in the first place. To get more info about the issue I tried running all the commands manually but alas, nothing.

The unity install folder is in the path.
I am not using the unity3d-builder plugin.

The log is as follows:

...
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Build Windows)
[Pipeline] bat
[rojectBright_game-CGUF3OHWBZNNV2VWAACJWLXACIDF7UD33WABSV4VPGISISZS6HYA] Running batch script

C:\Program Files (x86)\Jenkins\workspace\rojectBright_game-CGUF3OHWBZNNV2VWAACJWLXACIDF7UD33WABSV4VPGISISZS6HYA>Unity.exe -batchmode -executeMethod BOCBuild.BuildWindows -projectPath "C:\Program Files (x86)\Jenkins\workspace\rojectBright_game-CGUF3OHWBZNNV2VWAACJWLXACIDF7UD33WABSV4VPGISISZS6HYA" -logfile 
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Archive Windows)
Stage 'Archive Windows' skipped due to earlier failure(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline

GitHub has been notified of this commit’s build result

ERROR: script returned exit code 1
Finished: FAILURE

And the Jenkinsfile is:

pipeline {
  agent any
  stages {
    stage('Build Windows') {
      steps {
        bat 'Unity.exe -batchmode -executeMethod BOCBuild.BuildWindows -projectPath "%WORKSPACE%" -logfile'
      }
    }
    stage('Archive Windows') {
      steps {
        archiveArtifacts 'Build\\BOC-Windows*'
      }
    }
  }
}

And the BOCBuild class is:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class BOCBuild {
    public static void BuildWindows () {
		System.Console.WriteLine("Beginning Windows Build");
        string path = System.Environment.GetEnvironmentVariable("WORKSPACE");
        if (path == null) EditorApplication.Exit(1);
        BuildPipeline.BuildPlayer(EditorBuildSettings.scenes, path + @"\Build\BOC-Windows.exe", BuildTarget.StandaloneWindows64, BuildOptions.None);
		EditorApplication.Exit(0);
    }
}

Thanks for your help.

With Jenkins you should use the available Unity plugin:

https://wiki.jenkins.io/display/JENKINS/Unity3dBuilder+Plugin

source code:

Or, alternately, pipe the file C:\Users\AppData\Local\Unity\Editor\Editor.log to Jenkins, since that’s where Unity writes its output.