Unity3D & Jenkins Part 1- Setup Jenkins

Jenkins is a very dynamic build server, who can create build of almost everything. The advantage of build server is that you have a centralized place to keep your build configuration, you can do automatic testing and automatic deployment. One could argue that having a build server on a one-man project is overkill, but in my experience I tend to neglect build config and testing if I don’t automate it. Besides I learned something.

This build job was put on my Mac-Mini with OSX 10.9 (Maveriks). But a first a list of prerequisites

  • One build server (OSX Lion or better)
  • Java SDK (latest)
  • Jenkins install package (1.5.3.7)
  • Unity3D Pro (no command line acess otherwise)
  • Git (1.7.10) or later
  • Nothing else running on port 8080 (Jenkins uses it by default)
  • One auto-logged in OSX user (usually the deafult user)
  • A github account with a github project

Step 1– Install Jenkins

If you dont have the java SDK  download and install it from it from here. Second install Jenkins from here.

After running the jenkins installer, you should see something like this with the adress localhost:8080:

jenkins start screen

Jenkins start screen

Step 2 – Configure Jenkins user

Unfortunately the Unity3D engine requires that we change the standard installation and the setup of the box itself. Basically Unity#D needs access to the OSX windowsserver and todo that it needs to

  1. Run as a launchagent
  2. Be logged in (yes its annoying I know)

So open your terminal and enter the following:

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

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

This command moves the startup config from deamons to launchagents. But we not done yet, run the following command

nano /Library/LaunchDaemons/org.jenkins-ci.plist /Library/LaunchAgents/org.jenkins-ci.plist

Find the part that looks like this:

<key>UserName</key>
<string>whatever-username-your-logged-in-account-has</string>

You need Jenkins to run as the same user as the autologged in account or the Unity3D job simply wont run.

Now save and run the following command

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

Jenkin should start again and be ready for action.

Step 3 – Configure Jenkins Security

Jenkins is born with access for all, but we want to expose Jenkins to world and therefore we need to tighten security.

First a warning: Do not skip a step and do not press save until step 89 You will lock yourself out.

  1. Goto to Manage Jenkins->Configure Global Security
  2. Check Enable Security
  3. Select under Access Control-> Jenkins’s own user database
  4. Select Allow users to signup
  5. Check Matrix-based security
  6. Add a new user called <whatever>
  7. Enable all checkboxes for the <whatever> user
  8. Disable all checkboxes for the “Anonymous” user
  9. Press Save
  10. You are now logged out, create a new user
  11. Goto to Manage Jenkins->Configure Global Security and then disable Allow users to signup
Security settings should look like this - before you press save

Security settings should look like this – before you press save

Step 4 – Adding plugins

The plugins is what really makes Jenkins powerfull. For this part we need the Github plugin and the Unity3d plugin. Both are found under Manage Jenkins->Manage Plugins

Step 5 – Configuring Github

We want to create a webhook so that whenever a change is submitted to Github  a build is started on Jenkins. Goto Manage Jenkins->Configure System

1) find the Jenkins Location part and set the IP/DNS adress, remember if you are behind a router with a firewall you need to forward port 8080 to your local server

IP - Adress

IP – Adress

2) Find GitHub Web Hook and set the following and press save

web hook config

web hook config

3) Log in to your github account and go the project->settings->Service Hooks->Jenkins (Github plugin)

Github configuration

Github configuration

Step 6 – Configure Unity3D plugin

Goto Manage Jenkins->Configure System and set the unity location. On OSX it looks like the below.

Unity3d config

Unity3d config

This concludes the Jenkins server setup. The next part is the Job configuration

Useful Links

  • Nice blog about Jenkins and Xcode
  • How to create a dedicated user for Jenkins (wont work for Unity3D though)
  • Stackoverflow entry dealing with the windows server issue
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s