一、简述
Jenkins是一个广泛用于持续构建的可视化 web 工具,持续构建即各种项目的”自动化”编译、打包、分发部署。Jenkins 可以很好的支持各种语言(比如:java, c#, php等)的项目构建,也完全兼容 ant、maven、gradle 等多种第三方构建工具,同时跟svn、git 能无缝集成,也支持直接与知名源代码托管网站,比如 github、bitbucket 直接集成。
二、Jenkins 的安装
1、Jenkins本身是用 Java 语言开发的,所以安装 Jenkins 之前,要保证你的电脑有jdk,如果没有,可到如下链接下载安装:http://www.oracle.com/technetwork/java/javase/downloads/index.html


2、进入 Jenkins 的官网 http://jenkins-ci.org/ ,选择 Mac 直接安装。安装成功后。打开 http://localhost 查看是否可正常访问。

3、安装完成后,会直接跳转到如下界面,如果没有跳转或者跳转失败,可通过执行如下命令 "open /Applications/Jenkins/jenkins.war " 进入到该界面:

4、按照提示,找到 /Users/Shared/Jenkins/Home/ 这个目录下,这个目录虽然是共享目录,但是有权限的,非 Jenkins 用户 /secrets/ 目录是没有读写权限的。

5、修改权限打开 initialAdminPassword 文件,复制出密码,就可以填到网页上去重置密码了。如下图

6、安装插件,插件安装完成后,可能会卡在如下界面,不会自动跳转,刷新下界面即可:

7、在刷新后的界面中注册,输入用户名和密码,如下:


三、Jenkins 的使用
1、由于安装过程中,有些插件可能会安装失败,通过如下方式检查所需的插件是否安装成功。
通过“系统管理->管理插件->已安装“,检查如下所需的插件是否安装成功:
<1> Xcode integration ( Xcode 插件)
<2> Credentials Plugin (签名证书管理插件)
<3> Keychains and Provisioning Profiles Management (签名证书管理插件)
<4> GitLab Plugin
<5> Gitlab Hook Plugin
<6> Post-Build Script Plug-in
<7> Email Extension Plugin


2、构建项目



点击新建好的项目,进来配置一下 General 参数。

接着设置源码管理。
由于现在用到的是 GitLab,先配置 SSH Key,在 Jenkins 的证书管理中添加 SSH。在 Jenkins 管理页面,选择 “Credentials” ,然后选择 “Global credentials (unrestricted)” ,点击 “Add Credentials”,如下图所示,我们填写自己的 SSH 信息,然后点击 “Save” ,这样就把 SSH 添加到 Jenkins 的全局域中去了。
重点!!重点!!


构建环境设置
iOS 打包需要签名文件和证书,所以这部分我们勾选 “Keychains and Code Signing Identities” 和 “Mobile Provisioning Profiles”。
这里我们又需要用到 Jenkins 的插件,在系统管理页面,选择 “Keychains and Provisioning Profiles Management”。

点击 choose File 并上传 login.keychain 地址: /Users/ 管理员用户名 /Library/keychains/login.keychain. 上传成功后会出现:

点击 Add Code Signing Identity 添加对应的签名
3.上传 Provisioning Profiles 文件,Xcode 的 profile 存放在~/Library/MobileDevice/Provisioning Profiles/ 中

4、在系统管理->系统设置->Xcode Builder 中设置相关证书

五、回到项目配置->构建




六、构建成功后使用 fir 上传

关于 fir token 的获取,可以登录 fir, 进入个人中心生成 token
构建
返回项目首页,点击构建即可自动化打包上传

如果构建失败,可以在构建项的 Console Output 中查看构建信息

网友评论