[关闭]
@daaoling 2017-01-20T14:20:07.000000Z 字数 3311 阅读 2915

Unity Jenkins

Jenkins Unity Start

This's is 1th record for Unity Jenkins Toturial

Install jenkins

  1. brew install jenkins
  2. brew services start jenkins

Now, start open url http://127.0.0.1:8080/ to config jenkins service

Start setting

image_1b6taasjh1uvq5ecqnr17uo8lc9.png-59.9kB

上面这个密码jenkins启动的时候告诉你了

  1. 96fe05ac13d844028c59e3606f42442e
  2. This may also be found at: /Users/zjy/.jenkins/secrets/initialAdminPassword

Chose Pre-Install Plugins

Here is 2 options , one is auto pre-install plugins and the other manual selecl plugins to install.

First I chose the auto pre-install mode then someting worng when launch, So i have to uninstall jenkins then reinstall to clear the error.

the error like this below, some like plugins dependecne problem

  1. Jan 20, 2017 1:47:00 PM SEVERE jenkins.InitReactorRunner$1 onTaskFailed
  2. Failed Loading plugin Pipeline Graph Analysis Plugin v1.3 (pipeline-graph-analysis)
  3. java.io.IOException: Pipeline Graph Analysis Plugin v1.3 failed to load.
  4. - Pipeline: Groovy v2.23 failed to load. Fix this plugin first.

Register, Enter Main Page

image_1b6tacmma1g0ou8k1ueuu90lncm.png-83kB

Uninstall jenkins

  1. brew uninstall jenkins => to erase /usr/local/bin/jenkins -> ../Cellar/jenkins/2.41/bin/jenkins
  2. rm -rf ~/.jenkins => to erase setting config save dir

Quick Start

Make Export Shell In Unity Project

  1. public class MyEditorScript {
  2. // If you want to return an error from the commandline process
  3. // you can either throw an exception which will cause Unity to exit with 1
  4. // or else call EditorApplication.Exit with a non-zero code.
  5. // If you want to pass parameters you can add them to the command line
  6. // and retrieve them inside the method using System.Environment.GetCommandLineArgs.
  7. [MenuItem("Build/BuildAndroidProject")]
  8. public static void BuildAndroidProject()
  9. {
  10. string AndroidProjectPath = Application.dataPath.Replace("Assets",string.Empty) + "AndroidProject";
  11. string[] commadnLineArgs = System.Environment.GetCommandLineArgs();
  12. PlayerSettings.bundleIdentifier = commadnLineArgs[commadnLineArgs.Length - 2];
  13. PlayerSettings.bundleVersion = commadnLineArgs[commadnLineArgs.Length - 1];
  14. string result = BuildPipeline.BuildPlayer(
  15. GetBuildScenes(),
  16. AndroidProjectPath,
  17. BuildTarget.Android,
  18. BuildOptions.AcceptExternalModificationsToPlayer);
  19. if(!string.IsNullOrEmpty(result)) throw new Exception(" BuildAndroidProject wrong cause : " + result);
  20. }
  21. static string[] GetBuildScenes()
  22. {
  23. List<string> names = new List<string>();
  24. foreach(EditorBuildSettingsScene e in EditorBuildSettings.scenes)
  25. {
  26. if(e==null) continue;
  27. if(e.enabled) names.Add(e.path);
  28. }
  29. return names.ToArray();
  30. }
  31. }

BuildPlayer excetion will not fail the building process
And if/catch can't catch exception in BuildPlayer

So you only judge return value to judge the result and throw exception manually or use EditorApplication.Exit to fail the building process if return value is not empty

Install unity plugins

Install unity plugins for jenkins in jenkins plugins
manager First, Then According To Unity jenkins doc, You can specify Unity path.

image_1b6u3ce1t1tda10nd16eq1mtg1tj02a.png-58.3kB

Start Build

1.New A Task

image_1b6u26m3qkcmoef1veh15p43qc9.png-32.5kB
image_1b6u28aiaiht1km8176a1l6813s0m.png-99.9kB

2.Config Build Args

image_1b6u2hc18qb31306cg018k511ql1g.png-51kB

3.Config Build Shell

image_1b6u29kss7jt1jc41dc81br75113.png-45.6kB

Command line details

  1. Unity4
  2. -quit -batchmode -projectPath /Users/zjy/Exercise/BuildTest -executeMethod MyEditorScript.BuildAndroidProject "$bundleIdentifier" "$bundleVersion"

There, bundleIdentifier and bundleVersion set by Config Build Args and use to Unity Editor Script

4.Build

In the end, save and apply the config, Let's Build

image_1b6u2n772jgi15oe1kbt18dho0t1t.png-58.9kB

Either red or bule point in build histroy means you build finish.

Red means fail in build process. you can select log output message window to fix it.

image_1b6u3iuhc2hpq1blu2k92dq34.png-26.2kB

Notice

If you want to other compuer to access you jekins website,
you should modify you httpListenAddress = 0.0.0.0

image_1b6u3m39efg2n37dduqrt1cnc3h.png-124.9kB

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注