14

I'm trying to build Unity project with Jenkins on Mac OS Server. But when I try to run the following script

/Applications/Unity/Unity.app/Contents/MacOS/Unity -quit -batchmode ${PROJECT_PATH} -executeMethod BuildScript.DevelopmentBuild

The script shows this,

_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.

Does anyone knows how to fix the problem?

Chris Tavares
  • 29,165
  • 4
  • 46
  • 63
morodomi
  • 471
  • 1
  • 5
  • 12
  • Now I fixed the problem. I moved Jenkins CI from `/Library/LaunchDaemons/` to `/Library/LaunchAgents/`. Also I made jenkins user and install Unity3D on jenkins user. Then keep logged in jenkins user. – morodomi Sep 27 '13 at 02:28

6 Answers6

13

Try write from Terminal:

sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
sudo mv /Library/LaunchDaemons/org.jenkins-ci.plist /Library/LaunchAgents/org.jenkins-ci.plist

Then log out and log in again.

Now Jenkins will run as agent and can access WindowServer.

artoby
  • 1,614
  • 16
  • 13
  • 1
    I had to restart my machine after this change. Logging out and logging in wasn't enough. Also I don't have Jenkins configured to run on machine startup, so I had to run `sudo launchctl load /Library/LaunchAgents/org.jenkins-ci.plist` after restarting. – Liron Yahdav Aug 10 '14 at 20:13
  • Did also had to restart the machine, but after that it just worked fine! thx – d4Rk Jan 30 '15 at 10:18
4

Make sure you have -nographics parameter among your startup parameters

PVejchoda
  • 41
  • 2
1

I tried

sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist

sudo mv /Library/LaunchDaemons/org.jenkins-ci.plist /Library/LaunchAgents/org.jenkins-ci.plist

Then Restarted my Mac

And then sudo launchctl load /Library/LaunchAgents/org.jenkins-ci.plist after restarting

It worked

jsamol
  • 3,042
  • 2
  • 16
  • 27
0

I had this same issue. The problem is with how Jenkins and Unity work individually. The only way I could find a cleaner work around was:

  1. Ideally have your Jenkins master only do assignments to slave and do not build anything by itself. So your slaves would build the project.
  2. In case above is not easily doable here is a quick workaround:
    • On your Jenkins master create a slave.
    • Add a label to execute your Unity project on the newly created slave.
    • Configure the job to run on dedicated slave that you created above.
    • All works now!
0

You also get this error if the user you are running as is not currently logged in graphically.

Timmmm
  • 88,195
  • 71
  • 364
  • 509
-1

It looks like you're missing the --projectPath option prior to specifying your project's path?

Superpig
  • 763
  • 5
  • 10
  • I tried with --projectPath option as Unity -batchmode -quit -projectPath "${UNITY_PROJECT_PATH}" -executeMethod BuildScript.DevelopmentBuild. But won't build. – morodomi Jan 16 '13 at 07:58