Jenkins自动构建Unity
1.下载安装Jenkins
2.安装推荐plugins
NOTE:安装失败的话,后面进入管理plugins的高级选项中,将更新站点设置为:http://mirror.xmission.com/jenkins/updates/current/update-center.json。
2.1.安装Unity3d plugin。
3.创建新任务
3.1.在Configure中新增build step,选择Unity,设置命令行参数-quit -batchmode -projectPath "E:/Project Files/Unity Project/2018.3/jenkins" -executeMethod Jenkins.AutoBuild -logFile build.log Version-$Version。
3.2.build environment中勾选Add timestamps to the console output,为每个命令输出添加时间戳,方便后期查找。
3.3.设置SVN版本控制
3.4.新增命令行参数,其中参数以$Version的形式存在
3.5.丢弃旧的构建,保证磁盘不会出现占满的情况。
4.添加Unity Editor脚本。
public class Jenkins : Editor
{
private static string[] SCENES = FindEnabledEditorScenes(); private static string APP_NAME = "Jenkins";
private static string TARGET_DIR = "E:/Project Files/Unity Project/2018.3/jenkins/Build";
private static string JDK_DIR = "F:/Program Files/Java/jdk1.8.0_25";
private static string ANDROID_SDK_DIR = "F:/AndroidSDK"; 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();
} [MenuItem("Jenkins/Auto Build")]
public static void AutoBuild()
{
//Jenkins使用system账号,读取注册表路径为HKEY_USER;手动打开Unity使用user账号,读取注册表路径为HKEY_CURRENT_USER;
EditorPrefs.SetString("jdkPath", JDK_DIR);
EditorPrefs.SetString("AndroidSdkRoot", ANDROID_SDK_DIR); string version = GetJenkinsParameter("Version"); string suffix = string.Empty;
#if UNITY_STANDALONE_WIN
suffix = ".exe";
#elif UNITY_ANDROID
suffix = ".apk";
#elif UNITY_IOS
suffix = ".ipa";
#endif string targetFilePath = TARGET_DIR + "/" + APP_NAME + "_" + version + suffix; GenericBuild(SCENES, targetFilePath, EditorUserBuildSettings.activeBuildTarget, BuildOptions.None);
} public static void GenericBuild(string[] scenes, string target_dir, BuildTarget build_target, BuildOptions build_options)
{
BuildReport report = BuildPipeline.BuildPlayer(scenes, target_dir, build_target, build_options);
Debug.Log(report);
} private static string GetJenkinsParameter(string paramName)
{
foreach (var command in Environment.GetCommandLineArgs())
{
if (command.StartsWith(paramName) == true)
{
return command.Split('-')[1];
}
}
return string.Empty;
}
}
Jenkins自动构建Unity的更多相关文章
- Gitlab源码库里代码提交后,如何触发jenkins自动构建?
版本库里代码提交后,如何触发jenkins自动构建?这是一个面试题,感觉自己回答的并不好,因为并没有用过这个功能,之前公司实际项目用的是svn版本管理,一般都用立刻构建,和定时任务构建(不管代码是否有 ...
- 使用Docker+Jenkins自动构建部署
环境 Windows 10 Docker Version 18.06.1-ce-win73 (19507) 运行jenkins 运行jenkins 容器 docker run -d --name ln ...
- Gitlab使用Webhook实现Push代码后的jenkins自动构建
本文出自https://www.cnblogs.com/kevingrace/p/6479813.html 怕以后找不到,所以先写到自己博客中 Gitlab利用Webhook实现Push代码后的jen ...
- 实战:向GitHub提交代码时触发Jenkins自动构建
当我们提交代码到GitHub后,可以在Jenkins上执行构建,但是每次都要动手去执行略显麻烦,今天我们就来实战Jenkins的自动构建功能,每次提交代码到GitHub后,Jenkins会进行自动构建 ...
- DEVOPS技术实践_02:jenkins自动构建项目
一.用户名密码错误 打开jenkins发现用户名密码错误,解决 1.1 找到config.xml文件 [root@jenkins-master ~]# ll -a drwxr-xr-x. root r ...
- 小伙伴想学Jenkins自动构建发布项目,我:安排上了!!
写在前面 趁着十一长假,很多小伙伴都在悄悄学习,有些是为了能够顺利通过面试,进入大厂升职加薪.有些则是为了进一步巩固和提高自己的专业技能,希望有朝一日能过成为互联网架构师乃至技术专家.这不,就有小伙伴 ...
- Gitlab利用Webhook实现Push代码后的jenkins自动构建
之前部署了Gitlab的代码托管平台和Jenkins的代码发布平台.通常是开发后的代码先推到Gitlab上管理,然后在Jenkins里通过脚本构建代码发布.这种方式每次在发版的时候,需要人工去执行je ...
- SVN怎么触发Jenkins自动构建
通常,有几种方式可以在SVN仓库发生改变时触发Jenkins进行构建.第一种是,Jenkins主动轮询SVN仓库:第二种是,在SVN客户端(如TortoiseSVN)创建客户端hooks来触发构建:第 ...
- coding利用Webhook实现Push代码后的jenkins自动构建
安装jenkins 篇:http://www.cnblogs.com/loveyouyou616/p/8714544.html 之前部署了持续集成工具jenkins.通常是开发后的代码先推到 远程代码 ...
随机推荐
- 洗礼灵魂,修炼python(50)--爬虫篇—基础认识
爬虫 1.什么是爬虫 爬虫就是昆虫一类的其中一个爬行物种,擅长爬行. 哈哈,开玩笑,在编程里,爬虫其实全名叫网络爬虫,网络爬虫,又被称为网页蜘蛛,网络机器人,在FOAF社区中间,更经常的称为网页追逐者 ...
- Unity Chan 3D Asset
Unity Chan 3D Asset 我真的很久沒再家裡開unity,不過今天让我久违的開了 下载地址 :http://ref.gamer.com.tw/redir.php?url=http%3A ...
- Centos7下crontab+shell脚本定期自动删除文件
问题描述: 最近有个需求,就是rsync每次同步的数据量很多,但是需要保留的数据库bak文件 保留7天就够了,所以需要自动清理文件夹内的bak文件 解决方案: 利用shell脚本来定期删除文件夹内的任 ...
- emacs org-mode文件转html文件
Table of Contents 1. 发布站点 by emacs org-mode 1.1 org-mode 自带的导出方法 1.2 批量导出 1.3 css 美化 1.4 导出html 1. 发 ...
- January 23rd, 2018 Week 04th Tuesday
Remembrance is a form of meeting, forgetfulness is a form of freedom. 记忆是一种相遇,遗忘是一种自由. Cherish those ...
- 在pycharm中每次运行代码不使用console而使用run
问题:在pycharm中点击run运行程序,发现没有打开run窗口,而是打开的Python console窗口. 解决方法:打开菜单栏run->edit configurations,把下图中的 ...
- mac系统如何在当前目录下打开终端
给大家推荐一个好用的终端工具 Go2Shell:https://itunes.apple.com/cn/app/go2shell/id445770608?mt=12 在没有这个工具之前 找了好多在当前 ...
- Iris框架源码阅读和分析
iris包结构简介 iris包含了很多包,下面这些是分析过程中接触到的东西. 能力有限,多多包涵,欢迎联系QQ:2922530320 一起交流 context包包含: Context (接口) con ...
- oracle sqlplus 回退键以及上下键
Linux中安装完Oracle后,默认的 sqlplus 上下键是不能用的,安装了 rlwrap 之后就能通过上下键翻回历史命令了 下载地址 https://github.com/hanslub42/ ...
- nodejs-stream部分
参考: https://blog.csdn.net/eeewwwddd/article/details/81042225 http://nodejs.cn/api/stream.html#stream ...