iOS 持续集成

编程入门 行业动态 更新时间:2024-10-17 07:30:06

<a href=https://www.elefans.com/category/jswz/34/1770014.html style=iOS 持续集成"/>

iOS 持续集成

今天用Jenkins+iOS+fir+蒲公英 搭建持续集成环境,把过程记录一下。

第一步:安装Jenkins

方法一:直接去官网下载安装包

下载地址:/ 
下载后直接点击进入安装

安装完成后在Terminal中输入命令,打开Jenkins:

open /Applications/Jenkins/jenkins.war

方法二:使用命令行安装

1.安装 home-brew(安装指导)

ruby -e “$(curl -fsSL )”

2.安装 Jenkins

$ brew install jenkins

3.启动 Jenkins

$ jenkins

4.在浏览器输入地址:

http://localhost:8080/

使用安装包安装后会自动打开,如果端口冲突那么请修改端口

defaults write/Library/Preferences/org.jenkins-ci httpPort 8888

第二步:启动Jenkins后使用浏览器访问Jenkins

http://localhost:8080/

访问成功后显示如下:

第三步:安装插件

在“系统管理” -> “插件管理”中添加如下这个插件:

Xcode integration

左边菜单栏找到插件管理

第四步:新建项目

(1)新建项目

点击左侧工具栏”新建”, 
输入项目名称, 
选择第一项”构建一个自由风格的软件项目”

(2)基本信息

(3)源码管理信息

如果你是用的是Git,那就请选择Git,然后输入你的仓库地址:

如果你是用的是SVN,那就请选择Subversion,然后输入你的仓库地址:

(4)自动构建时机

这里就是告诉jenkins什么时候自动构建,当然也可以不设置。

关于定时器的格式,我只能从网上摘抄一段稍微靠谱一点的说明:

This field follows the syntax of cron (with minor differences). Specifically, each line consists of 5 fields separated by TAB or whitespace:MINUTE HOUR DOM MONTH DOWMINUTE Minutes within the hour (0-59)
HOUR The hour of the day (0-23)
DOM The day of the month (1-31)
MONTH The month (1-12)
DOW The day of the week (0-7) where 0 and 7 are Sunday.To specify multiple values for one field, the following operators are available. In the order of precedence,* '*' can be used to specify all valid values.* 'M-N' can be used to specify a range, such as "1-5"* 'M-N/X' or '*/X' can be used to specify skips of X''s value through the range, such as "*/15" in the MINUTE field for "0,15,30,45" and "1-6/2" for "1,3,5"* 'A,B,...,Z' can be used to specify multiple values, such as "0,30" or "1,3,5"Empty lines and lines that start with '#' will be ignored as comments.
In addition, @yearly, @annually, @monthly, @weekly, @daily, @midnight, @hourly are supported.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

举两个例子:

// every minute
* * * * *
// every 5 mins past the hour
5 * * * *
  • 1
  • 2
  • 3
  • 4
  • 1
  • 2
  • 3
  • 4

(5)构建

添加构建步骤 -> Xcode基本信息

这里Target请于Xcode项目中Target的名字对应Clean before build设置为YESConfiguration我选择了Release(在Release的时候Archive).ipa filename pattern 随便起个.ipa的名字Output directory为.ipa的输出路径,我这里设置为 ${WORKSPACE}/build/
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

添加构建步骤 -> Xcode证书信息

我这里是在上传至Git的项目里已经配置过证书和Provisioning Profiles。

打开Unlock KeychainKeychain path 设置为 ${HOME}/Library/Keychains/login.keychainKeychain password 为你钥匙串的密码
  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5

login.keychain的路径在哪?

点击”系统管理”中的”系统设置”,Xcode Build中的Keychains

注意! 
如果项目使用了cocoapods,需要配置Advanced Xcode build options,设置

  1. Schema

  2. SDK iphoneos

  3. Workspace File(不用加.xcworkspace)

  4. Build output directory 也设为${WORKSPACE}/build/

(6)构建后操作

添加构建后操作步骤

1.你可以选择上传到fir:

fir的地址:/

也可以选择上传到蒲公英:

蒲公英的地址:/

2.你也可以选择命令行

Execute a set of scriptsAdd build stepExecute shell在Commas中输入fir p ${WORKSPACE}/build/SinocareDevice.ipa -T #API Token#
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

新版fir.im的API Token获取方式见下面:

请注意,在使用该命令前请先确认安装fir-cli,安装命令如下:

Mac OS X 10.11 以后的版本, 由于10.11引入了 rootless, 无法直接安装 fir-cli, 有以下三种解决办法:

1.使用 Homebrew 及 RVM 安装 Ruby, 再安装 fir-cli(推荐)

# Install Homebrew:
$ ruby -e "$(curl -fsSL )"# Install RVM:
$ \curl -sSL  | bash -s stable --ruby$ gem install fir-cli
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

2.指定 fir-cli 中 bin 文件的 PATH

$ export PATH=/usr/local/bin:$PATH;gem install -n /usr/local/bin fir-cli
  • 1
  • 1

3.重写 Ruby Gem 的 bindir

$ echo 'gem: --bindir /usr/local/bin' >> ~/.gemrc
$ gem install fir-cli
  • 1
  • 2
  • 1
  • 2

上面的命令来自 fir.im 的工具 fir-cli,这是他们的官方使用说明

fir.im测试平台通过他自家的工具fir-cli上传ipa包:

fir p ${WORKSPACE}/build/ipa/SinocareDevice.ipa -T eb403ebb9f85de494646d86d48
  • 1
  • 1

蒲公英测试平台通过curl上传ipa包:

curl -F "file=@${WORKSPACE}/build/ipa/SinocareDevice.ipa" -F "uKey=b122767e218b501d0d3434f5aeb" -F "_api_key=88c9a97bc31211919eaf4bf5ba3a" 
  • 1
  • 1

完成,点击保存。

(7)点击立即构建

构建成功标志位置为蓝色,失败为红色。

查看fir.im,应用上传成功:

查看蒲公英,应用上传成功:

原地址:

更多推荐

iOS 持续集成

本文发布于:2024-02-06 12:35:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1748916.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:iOS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!