📜 ⬆️ ⬇️

Building Unity3D builds on Jenkins on Mac OS X. Part 1

Prehistory


There is a project on Unity3D . There are already several years (born in February 2012). After six months, I started working on it as a programmer, and after two years I was not lucky and I became responsible for building the builds. I inherited MacMini with the Jenkins collector installed, a minimum of documentation and the lack of an adequate build for iOS .

I would like to finally write an adequate instruction - for the initial setting was killed a few weeks, and when you transfer to the iMac, my old practices are already outdated. So…

Technical task


  1. The project is being developed on the Unity3D engine. Since development has been going on for a long time, the engine version has changed from 3.5.6 to 4.6.6 (at the time of this writing, support version 5 is not planned yet). Each version has its glitches, some versions contain vital edits for one platform and at the same time kill the assembly for another. For example, support for 64b for iOS has been added in recent versions, in early 4.x versions there was an assembly for the Google Chrome and Flash plugin, the recommended Android SDK changes from version to version. You need to have everything.
  2. The project is on the svn server. Specifically - subversion.assembla.com . Need support for the assembly of different branches, different subprojects, as well as projects that include parts of other projects.
  3. The build should be carried out for Android ( Google Play , Amazon App Store , Yandex Store ...), iOS , Windows , Mac OS , Linux (all with the possibility of publishing on Steam ). Some parts are set to run in the browser. Here we consider only the features of the assembly for each configuration.
  4. You need access to builds from the local network so that the tester can download, install and test.
  5. Standalone build, autorun after failure (power off)

Iron


Why we collect on apple products? Because you need to collect iOS applications and send them to the AppStore . Have a hackintosh or virtualka - have problems.

So, there is an old MacMini in the office and the newest iMac at home. Both cope with their work, the difference in performance and approach - there is no guarantee for the first one and it is not a pity for him (the desire to kill him on the table occurs every week), the second one is lovingly wiped with a rag and protected.
')
So, for those who want - to get acquainted with the assembly and disassembly of the first device - welcome here . The need for assembly arose after the death of the old disk. Thanks to the instructions, the new 1 TB disk has been successfully opened and inserted.

It is worth making a digression here - I prefer to have a hard disk with several partitions, and maybe even with several operating systems. However, if the type of drive is Fusion Drive , this will not work (my iMac has a maximum of two disks on the disk, and the second one is inhabited by Windows ). If the drive is normal - no problems. You can store all the important data in one section (and backup it with Time Machine ), and store heavyweight copies of the project on another.

System installation


Deserves a separate article. Briefly:

  1. On the latest poppies there is an online installation. Otherwise - you need a drive or flash drive with the image of the system. Enter the Cmd + R installation menu.
  2. All disks and sections we call clear names. Sections with system and working data are formatted necessarily in Mac OS Extended (Journaled) . Required - not Case-sentive .
  3. To install the software, you need an Apple Id . It is desirable that this Apple Id match the account of the Apple developer , which is used in the preparation and pouring builds.
  4. In addition to the administrator account, we do not need to bind an account with normal rights. We call it jenkins , password also.
  5. If someone needs remote access via Chrome Remote Desktop , you’ll have to give the account administrator privileges.
  6. We put a normal browser and useful software at will.
  7. If you have problems with the display of pages - Steam Community , YouTube and others - we look once and twice .

Install Xcode


  1. The latest version is usually put from the store.
  2. When installing multiple versions - it is desirable to select a separate folder and put it there. For example - in / Applications / Xcode are Xcode_5_1_1.app and Xcode_6_1_1.app .
  3. Old versions can be found here .

Install Unity3D


The engine can be downloaded on offsite (need Mac version) version or on your favorite tracker . On the off-line, we register and purchase the necessary license , depending on the needs of the project.

By default, after installing Unity.app , MonoDevelop.app and the documentation are in / Applications / Unity . If you need to install several versions, first rename the old installation folder, for example / Applications / Unity_4_6_6_f2 , only after that we install the new version and rename the installation location too. All versions and patches can be found here .

MonoDevelop is sufficient to leave the freshest, having written the path in the settings of each Unity . In the folder / Users / Shared, you can find the default Unity project - it can be demolished.

For the user jenkins, you must add rights to run all files. If necessary - and all the contents .app .

Also in the settings disable the auto-discovery of the last project and register each copy.

Install Java, JDK, Android SDK


JDK and JRE can be downloaded from offsite . Android SDK download from here . After installation, we update the SDK and set the path to it in each Unity and check it on the test build. An example of a working configuration:

The configuration is selected only by experience. There is no guarantee that when upgrading one of these components, the build of the build will not fall ...

SVN installation


According to this - subversion comes with the system. To install a specific version - I recommend using Homebrew , we are looking for more details here .

Install Jenkins


  1. All operations are performed under the user jenkins
  2. Downloading from the offsite installer. We put, move to a convenient place, for example in /Users/jenkins/WORK/JENKINS_WAR/jenkins.war
  3. Go to the terminal, execute the command to start the collector:

    java -jar /Users/jenkins/WORK/JENKINS_WAR/jenkins.war 

  4. Check in the browser - 127.0.0.1:8080 for the presence of a collector. After closing the terminal (the collector is disabled)
  5. Create a folder for temporary files. For example - / Users / jenkins / WORK / JENKINS_TMP
  6. Create a folder for the collector. For example - / Users / jenkins / WORK / JENKINS_HOME . In it we copy the contents of the /Users/jenkins/.jenkins folder, and delete the folder itself.
  7. Go to the terminal and log in as administrator:

     login dimamatik 

  8. Delete the old configuration file:

     sudo rm /Library/Preferences/org.jenkins-ci.plist 

  9. Enter the following parameters (can be changed, if desired):

     pp="/Library/Preferences/org.jenkins-ci.plist" sudo defaults write $pp JENKINS_HOME "/Users/jenkins/WORK/JENKINS_HOME" sudo defaults write $pp tmpdir "/Users/jenkins/WORK/JENKINS_TMP" sudo defaults write $pp war "/Users/jenkins/WORK/JENKINS_WAR/jenkins.war" sudo defaults write $pp httpPort 4242 

  10. Checking:

     defaults read $pp 

  11. We install the rights:

     sudo chown root:wheel $pp sudo chmod 644 $pp 

  12. We unload the jenkins demon with the command:

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

  13. Remove the demon:

     sudo rm /Library/LaunchDaemons/org.jenkins-ci.plist 

  14. We leave from the administrator:

     logout 

  15. We start the collector through the terminal once again (the page is now 127.0.0.1:4242 ). Everything should work .

More details can be found here and here .

Autoload, restart, death


The problem of death and resuscitation of the collector is aggravated by the use of Mac and assembly on Unity . We write and save scripts:


To automatically start the collector, create a special application using Automator . Select the AppleScript Run template and create jenkins-restart.app in the same folder as the rest of the scripts. Program code below:

  on run {input, parameters} tell application "Terminal" activate if (the (count of the window) = 0) or (the busy of window 1 = true) then tell application "System Events" keystroke "n" using command down end tell end if do script "sh ~jenkins/jenkins-restart.sh" end tell return input end run 


If the scripts are not in the home folder, edit the paths accordingly.

In the jenkins user settings we set the automatic launch of the written application. If desired, it can be used manually. We put the user on the automatic login when the system starts (if it is an office collector, and we are too lazy to come early to start it).

Learn more about the daemon - look at the wiki or in the general help . Generally speaking, it would be possible not to use Automator , but to leave this mechanism by adding unloading and loading of the daemon in the scripts. However, the plug-in and reboot plugins may not work correctly.

What we have


At the moment, the system should work . The collector (while empty) automatically starts at system startup. Any project on Unity should normally be assembled (by hand) from under the jenkins user. If errors occur - we look at the permissions, the installed components, we pay debts for the license. The most interesting thing to come ...

The second part can be found here .

Update 10/6/15

  1. Added paragraph on the Jenkins daemon, fixed instructions for disabling it.
  2. Added link to offsite in the section about downloading and installing the collector.
  3. Comment for script and application restart.

Update 10/13/15

  1. Added link to the second part.
  2. Added die tutorial.

Source: https://habr.com/ru/post/268233/


All Articles