Due to some maintenance issues, this service has been switched in read-only mode, you can find more information about the why

and how to migrate your plugin documentation in this blogpost

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 14 Next »

Plugin Information

View Unity3d on the plugin site for more information.

A problem, An idea ?

Please use our tasks and issues tracker to report bugs, improvements or new feature.

Also if you want to propose some code change using a Github pull request, please open also a Jira issue. It is easier for developers to track them.

Unity3d is a powerful 3d game creation editor and engine that runs on Mac and Windows.

This plugin adds the ability to call the Unity3d Editor from the command line to automate build and packaging of Unity3d applications.

Table of content

Background

Automating Unity3d builds from the command line is possible. There are a few problems though:

  • the unity runner writes its output to a separate log file, instead of the output
  • tool and file locations are platform specific
  • only one project can be built at a time per machine

Features

This plugin aims to make it easier to run Unity3d builds easily in Jenkins, by adding the following features:

  • log file redirection
  • distributed builds

The plugin was tested with unity3d 3.4.2 and unity3d 3.5 beta. Tested on distributed and single server environments

Documentation

Installation guide

As Unity3d is multi-platform, you may need to install the proper third party OS & tools (Android SDK, XCode, etc) depending on the type of build targets you intend to exercise.

Install the latest version of the plugin from the update center and configure a freestyle job (see #Usage Guide). If necessary restrict the job to the node(s) that will perform the build(s).

On the node(s) you are going to build Unity projects, add at least one unity3d installation (Manage Jenkins -> Configure System) and configure the location of the Unity3d installation. This location is by default /Applications/Unity/Unity.app on Mac OS X and C:\Program Files (x86)\Unity on Windows. The plugin will automatically suffix the installation path with the proper executable location.

Usage guide
Prerequisites

The plugin assumes you've created a special Editor class with at least one method responsible for your build.

Here's an example extracted from one of our projects:

Assets/Editor/MyEditorScript.cs

class MyEditorScript {
        static string[] SCENES = FindEnabledEditorScenes();

        static string APP_NAME = "YourProject";
        static string TARGET_DIR = "target";

        [MenuItem ("Custom/CI/Build Mac OS X")]
        static void PerformMacOSXBuild ()
        {   
                 string target_dir = APP_NAME + ".app";
                 GenericBuild(SCENES, TARGET_DIR + "/" + target_dir, BuildTarget.StandaloneOSXIntel,BuildOptions.None);
        }

	private static string[] FindEnabledEditorScenes() {
		List<string> EditorScenes = new List<string>();
		foreach(EditorBuildSettingsScene scene in EditorBuildSettings.scenes) {
			if (!scene.enabled) continue;
			EditorScenes.Add(scene.path);
		}
		return EditorScenes.ToArray();
	}

        static void GenericBuild(string[] scenes, string target_dir, BuildTarget build_target, BuildOptions build_options)
        {   
                EditorUserBuildSettings.SwitchActiveBuildTarget(build_target);
                string res = BuildPipeline.BuildPlayer(scenes,target_dir,build_target,build_options);
                if (res.Length > 0) {
                        throw new Exception("BuildPlayer failure: " + res);
                }
        }
}
User/OS setup

On Mac OS X, the user running needs to be logged in otherwise the Unity3d editor might fail to acquire the graphical resources. FIXME add a log.

Build queue

The Unity Editor can only perform one build at a time. If you have multiple job, you may want to prevent more than one Unity jobs to be running at the single time. One simple way to achieve this is to have a single Executor on your build server node. This has of course drawbacks if you intend to run other types of jobs on the same node that are not affected by the same limitation.

Setting up a build step

Add the Unity3d build step to a free-style project, select the unity3d installation and set your command line arguments (e.g. -quit -batchmode -executeMethod MyEditorScript.PerformMacOSXBuild). If you do not specify -projectPath, the plugin will use the current workspace. You may want to add an extra step to clean the project before you build to make sure the build starts in a clean state.

If you want to build for iOS, you will have to add extra build steps to trigger xcode build. This step isn't covered here.

Unity3d Builder configuration parameters

Parameter

Since version

Description

command line

0.1

The full command line, the builder adding the -projectPath if it isn't specified

Friendly plugins

  • The Log Parser Plugin can help you to quickly set some parsing rules for your Unity3d builds. Here's a tentative set of rules that we use in one project:
    start /^Initialize mono/
    start /^- starting compile/
    start /^Mono dependencies included in the build/
    start /^Textures/
    info /^Complete size/
    warning /warning CS/
    error /error CS/
    start /^-----CompilerOutput:-stdout/
    info /^Compilation succeeded/
    error /^Compilation failed/
    start /^Used Assets, sorted by uncompressed size/
    info /^\*\*/
    info /^Exiting batchmode successfully now/
    start /^=== BUILD NATIVE TARGET/
    start /^Packaging IPA/
    start /^Archiving artifacts/
    start /Uploading to testflight/
    

Known issues

type key summary assignee reporter priority status resolution created updated due

Data cannot be retrieved due to an unexpected error.

View these issues in Jira

Related information

Changelog

Version 0.4 (DEV IN PROGRESS)
Version 0.3 (06.06.202)
  • Validity of Unity3D project folder was not correctly checked when projectPath parameter was used.
Version 0.2 (30.01.2012)
  • JENKINS-12590
Version 0.1 (24.01.2012)
  • live redirection of the Editor.log file into the console
  • supports distributed builds
  • automatically adds the -projectPath command line
  • No labels