Concurrent builds on Jenkins wait each others

Hi,

We have Jenkins agents set up to run concurrent builds on our project. The issue is that Unity gets stuck right before quitting if another build occurs during the process on the same agent.

For example:

  • Builds take 20 minutes
  • Build A starts at 10:00
  • Build B starts at 10:10
  • Build B & A ends at 10:30

We are launching every build with this command line:

Unity.exe -projectPath . -buildTarget StandAloneWindows -executeMethod Automation.Cook -batchmode -nographics -accept-apiupdate -quit

This command is wrapped in a C# Process object which listens to onDataReceived, onErrorRecieved and onExited events.
With the previous example, last onDataRevieved event is caught at 10:20 but onExited is caught at 10:30, leaving a 10 minutes gap between the build completing and Unity actually quitting.

Is there any shared process or resource that could prevent Unity from exiting ?

Unity version : 2022.3.46 (LTS)
Target platform : Windows Standalone
Jenkins : 2.462.2 running on Windows 10

What version of Unity do you use? Windows or Linux host machine?
What are your target platforms for the build and the list of target platforms installed on the build machine?

I’m asking this because in the past I had similar issue, the build never stopped in Jenkins, even after the Unity process had exited.

After my investigation, I found that the builder had the Android target platform installed. ADB was started by Unity and never exited even after Unity quit and Jenkins was waiting.

Since at that time we didn’t build for Android, I uninstalled the Android build target from the builder (or deleted the adb.exe file from Unity installation, I don’t remember) and it fixed the issue.

Thanks for the reply !

Unity version : 2022.3.46 (LTS)
Target platform : Windows Standalone
Jenkins : 2.462.2 running on Windows 10

Andoid build target is not installed on our Jenkins agents.
From the log, the only reference to ADB we get is a performance report dumped by Unity before quitting

[Performance] Application.Shutdown.ADBSaveStateBeforeShutdown …

Not sure if it’s related…

After further investigation, we identified that the issue was caused by not using the -logFile CLI parameter. When we set a unique log file path for each build, everything works as expected, and the builds no longer block each other.

However, here’s the problem: we intentionally avoided using the -logFile parameter and instead relied on onDataReceived because it allows us to output logs directly to the Jenkins console during the build process. This is extremely useful for real-time build monitoring, and we’d like to keep this functionality.

So, my new question is: Is it possible to have real-time Unity log events while also enabling concurrent builds to run without issues?

Additionally, we’re still unsure why builds hang at the quitting phase when Unity logs to stdout. Any insights into this would be greatly appreciated. We already tried to use FileSystemWatcher to read the log file as it is updated by the editor but we couldn’t read anything.