Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Why I can't build an Unity project by using Jenkins on MacOS?

Discussion in 'iOS and tvOS' started by guoxin, Jan 23, 2013.

  1. guoxin

    guoxin

    Joined:
    Jan 22, 2013
    Posts:
    4
    I am trying to do End-to-End automation for an Unity IOS project. My aim is to automate the continuous integration process with attaching UIAutomation scripts as post build action. So from the time when a user do check his code in SVN and till we get test result of automation, everything will be automated.

    Jenkins is installed on my local apple machine and running on local host.
    Now I have automated build process through jenkins and at other end I have my shell script ready which will run C# scripts on build output.
    When I use my shell script as post build action then I get error in running instrument command(written inside shell script) but if I run this script manually through terminal then it works fine:

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

    Please let me know how can I run these commands successful.Help!
     
  2. dreamychris

    dreamychris

    Joined:
    Aug 28, 2012
    Posts:
    7
    Yeah, I had that issue too. The problem is that the Unity editor requires access to the window server, since it insists on displaying a GUI even in batch mode. Thus, you can't run it from a daemon process (which is the typical setup for Jenkins).

    My hacky workaround was to use Applescript to launch a Terminal window and script it to run a secondary shell script (which in turns launches Unity, tails the log, launches xcodebuild, etc.).

    Yep, it's horrible! But I've been running this setup for several months now, and so far it hasn't caused any problems, apart from making it annoying to work directly on the build machine when it keeps popping up new windows (but you normally shouldn't be touching the build machine anyway). You can get fancy with output direction and tail -F to pass Unity's log output back to Jenkins, which makes it mostly seamless.

    It would be nice if Unity had a true headless mode. :)
     
  3. FatWednesday

    FatWednesday

    Joined:
    Jul 4, 2012
    Posts:
    50
    Chris, any more information you can provide on how you soled this problem ? I'm finding myself in a similar situation. When I install Jenkins to start as Daemon my build log on Jenkins does the following.

    Started by user anonymous
    Building in workspace /Users/Shared/Jenkins/Home/jobs/Unity_AutoBuildTest/workspace
    Updating https://integration-pc/svn/Projects/AutoBuildTest at revision '2013-04-16T14:05:20.937 +0100'
    At revision 3230
    no change for https://integration-pc/svn/Projects/AutoBuildTest since the previous build
    Piping unity Editor.log from /var/root/Library/Logs/Unity/Editor.log
    [workspace] $ /Applications/Unity_4/Unity.app/Contents/MacOS/Unity -projectPath /Users/Shared/Jenkins/Home/jobs/Unity_AutoBuildTest/workspace -quit -batchmode -executeMethod AutomatedBuildScript.PerformIOSBuild
    2013-04-16 14:05:23.149 Unity[52175:707] NSDocumentController Info.plist warning: The values of CFBundleTypeRole entries must be 'Editor', 'Viewer', 'None', or 'Shell'.


    Then hangs until the time-out kicks in and aborts the build.

    When I uninstall and instead install it to run as user 'Jenkins' I get the following.

    Started by user anonymous
    Building in workspace /Users/Shared/Jenkins/Home/jobs/Unity_AutoBuildTest/workspace
    Updating https://integration-pc/svn/Projects/AutoBuildTest at revision '2013-04-16T14:10:16.606 +0100'
    At revision 3230
    no change for https://integration-pc/svn/Projects/AutoBuildTest since the previous build
    Piping unity Editor.log from /Users/Shared/Jenkins/Library/Logs/Unity/Editor.log
    [workspace] $ /Applications/Unity_4/Unity.app/Contents/MacOS/Unity -projectPath /Users/Shared/Jenkins/Home/jobs/Unity_AutoBuildTest/workspace -quit -batchmode -executeMethod AutomatedBuildScript.PerformIOSBuild
    Initialize mono
    Mono path[0] = '/Applications/Unity_4/Unity.app/Contents/Frameworks/Managed'
    Mono path[1] = '/Applications/Unity_4/Unity.app/Contents/Frameworks/Mono/lib/mono/2.0'
    Mono config path = '/Applications/Unity_4/Unity.app/Contents/Frameworks/Mono/etc'
    Using monoOptions --debugger-agent=transport=dt_socket,embedding=1,defer=y
    _RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
    2013-04-16 14:10:18.475 Unity[52351:707] NSDocumentController Info.plist warning: The values of CFBundleTypeRole entries must be 'Editor', 'Viewer', 'None', or 'Shell'.


    and then also hangs until the time-out kicks in.
     
  4. sbeckstead

    sbeckstead

    Joined:
    Feb 22, 2013
    Posts:
    5
    Ask for the -nographics switch like the windows version has!
     
  5. softocean

    softocean

    Joined:
    Aug 19, 2008
    Posts:
    6
    I had some success using applescript with the following commands in a jenkins build shell script.

    Code (csharp):
    1.  
    2. # here is some test code
    3. osascript -e 'tell application "Terminal" to activate' 
    4. osascript -e '     
    5. tell application "Terminal"
    6.     do script "cd ~/" in window 1
    7.     do script "whoami" in window 1
    8.     do script "/path/to/Unity -projectpath /path/to/unity/project -quit -batchmode -executeMethod MyScript.PerformBuild" in window 1
    9. end tell'  
    I also had to make sure the files of the unity installation had the same group as the jenkins user.
     
  6. andi.radulescu

    andi.radulescu

    Joined:
    Aug 30, 2013
    Posts:
    1
    Jenkins by default installs as a LaunchDaemon, which means it has insufficient permissions to launch WindowsServer.

    You’ll need to configure it as a LaunchAgent:

    Code (csharp):
    1. sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
    2. sudo mv /Library/LaunchDaemons/org.jenkins-ci.plist /Library/LaunchAgents/org.jenkins-ci.plist
    Then login as Jenkins and keep a session open.

    If you don't know the Jenkins password you can change it with:

    Code (csharp):
    1. sudo passwd jenkins
     
  7. aureliendrouet

    aureliendrouet

    Joined:
    Feb 24, 2013
    Posts:
    4
  8. ynedelin

    ynedelin

    Joined:
    Jul 3, 2012
    Posts:
    14
  9. benlau-ml

    benlau-ml

    Joined:
    Aug 8, 2017
    Posts:
    1
  10. ericksson

    ericksson

    Unity Technologies

    Joined:
    Oct 31, 2009
    Posts:
    81