@daaoling
2017-01-20T22:20:07.000000Z
字数 3311
阅读 2975
Unity
Jenkins
This's is 1th record for Unity Jenkins Toturial
brew install jenkins
brew services start jenkins
Now, start open url http://127.0.0.1:8080/ to config jenkins service
上面这个密码jenkins启动的时候告诉你了
96fe05ac13d844028c59e3606f42442e
This may also be found at: /Users/zjy/.jenkins/secrets/initialAdminPassword
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
Jan 20, 2017 1:47:00 PM SEVERE jenkins.InitReactorRunner$1 onTaskFailed
Failed Loading plugin Pipeline Graph Analysis Plugin v1.3 (pipeline-graph-analysis)
java.io.IOException: Pipeline Graph Analysis Plugin v1.3 failed to load.
- Pipeline: Groovy v2.23 failed to load. Fix this plugin first.
brew uninstall jenkins => to erase /usr/local/bin/jenkins -> ../Cellar/jenkins/2.41/bin/jenkins
rm -rf ~/.jenkins => to erase setting config save dir
public class MyEditorScript {
// If you want to return an error from the commandline process
// you can either throw an exception which will cause Unity to exit with 1
// or else call EditorApplication.Exit with a non-zero code.
// If you want to pass parameters you can add them to the command line
// and retrieve them inside the method using System.Environment.GetCommandLineArgs.
[MenuItem("Build/BuildAndroidProject")]
public static void BuildAndroidProject()
{
string AndroidProjectPath = Application.dataPath.Replace("Assets",string.Empty) + "AndroidProject";
string[] commadnLineArgs = System.Environment.GetCommandLineArgs();
PlayerSettings.bundleIdentifier = commadnLineArgs[commadnLineArgs.Length - 2];
PlayerSettings.bundleVersion = commadnLineArgs[commadnLineArgs.Length - 1];
string result = BuildPipeline.BuildPlayer(
GetBuildScenes(),
AndroidProjectPath,
BuildTarget.Android,
BuildOptions.AcceptExternalModificationsToPlayer);
if(!string.IsNullOrEmpty(result)) throw new Exception(" BuildAndroidProject wrong cause : " + result);
}
static string[] GetBuildScenes()
{
List<string> names = new List<string>();
foreach(EditorBuildSettingsScene e in EditorBuildSettings.scenes)
{
if(e==null) continue;
if(e.enabled) names.Add(e.path);
}
return names.ToArray();
}
}
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 for jenkins in jenkins plugins
manager First, Then According To Unity jenkins doc, You can specify Unity path.
1.New A Task
2.Config Build Args
3.Config Build Shell
Command line details
Unity4
-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
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.
If you want to other compuer to access you jekins website,
you should modify you httpListenAddress = 0.0.0.0