- Home /
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.
@$$anonymous$$attDahEpic Did you ever find out the reason for this? I'm seeing this in 2019.3 and I can't figure out why; running the exact same batch command from command-line works fine, but in Jenkins the log just disappears.
@RG_Keith I ended up switching to using the linux docker continers provided by https://gitlab.com/gableroux/unity3d and using GitLab's built in CI runner. There have been some people finding success with using those containers under Jenkins though, so that might be the way to go.
Answer by cudreaUdev · Sep 28, 2017 at 07:28 AM
With Jenkins you should use the available Unity plugin:
https://wiki.jenkins.io/display/JENKINS/Unity3dBuilder+Plugin
source code:
https://github.com/jenkinsci/unity3d-plugin
Or, alternately, pipe the file C:\Users\\AppData\Local\Unity\Editor\Editor.log to Jenkins, since that's where Unity writes its output.
I cannot use the unity3d-builder as it does not work with the most recent version of jenkins and has not been updated in 2 years. I am looking for a pure jenkins only solution if possible.
With the current -logfile
argument, Unity is supposed to pipe its output to stdout. There is no localappdata unity editor folder.
Then it's likely caused by your command lacking the "-quit" argument.
Remember to add "-nographics" if you run Jenkins as a headless user (i.e: macOS or limited windows user).
Also, it's possible Unity might pipe some messages to stderr as well so add "2>&1" just to be sure.
Final command would be:
"Unity.exe -quit -batchmode -nographics -execute$$anonymous$$ethod BOCBuild.BuildWindows -projectPath "%WOR$$anonymous$$SPACE%" -logfile 2>&1"
EDIT: You should crash if the build fails. $$anonymous$$aybe even print the error.
string error = BuildPipeline.BuildPlayer(EditorBuildSettings.scenes, path + @"\Build\BOC-Windows.exe", BuildTarget.StandaloneWindows64, BuildOptions.None);
if( string.IsNullOrEmpty( error ) )
EditorApplication.Exit( 0 );
else
EditorApplication.Exit( 1 );
Damn this comment editor sucks.
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Segmentation Fault (Core Dump) Error when building 3D Scenes command line 0 Answers
Multiple Cars not working 1 Answer
Build hang on compiling scripts in Unity 2018.2 2 Answers
Flip over an object (smooth transition) 3 Answers