上一篇有讲关于fastlane自动化部署,本篇将会着重讲关于fastlane的实际应用。

目标:

  • 利用自动化jenkins打包工具,自动拉取git仓库代码
  • 不需要通过手动检查修改xcode中项目配置修改(provisioning,codesigning)
  • 支持多渠道(chanel,appstore,enterprise,develop,adhoc)
  • 支持一键上传appstore(首次需要输入账户,密码)
  • 企业版本自动上传序号dsym文件到对应平台(fir的hdbug平台)

创建fastlane文件

进入项目目录在终端输入fastlane init命令,会要求输入Apple ID信息按照提示输入即可,选择是否deliver等初始化工作按照上篇讲解即可。操作完成即可看到下图所示的基本内容,下面会对图中文件一一讲解:

fastlane源码解析

一. 统一管理fastlane操作脚本文件

1.外界控制版本号,并且控制渠道AdHoc AppStore Develop InHouse

1
2
3
4
versionNumber=$2 # 1.0.0
outLaneName=$1 #"AdHoc AppStore Develop InHouse"其中的一种,外界传入
curDir=`pwd`
distDir="$curDir/build"

2.根据外界传递的数据控制,调用fastlane的lane操作

1
2
3
4
5
6
7
8
9
basicLanes="AdHoc Release Develop InHouse"
for laneName in $basicLanes
do
if [ $outLaneName == $laneName ]
then
echo "outer setValue is:$outLaneName"
fastlane $laneName version:$versionNumber
fi
done

二. Appfile文件修改

1.同一个app,appfile控制渠道(appstore非appstore的)。当然也可以通过控制多个app区分不同的lane即可

1
2
3
4
5
6
app_identifier "com.tww.test" # App Store的版本的app_idendifier
apple_id "2501046883@qq.com" # 对应的账号appid
for_lane :InHouse do #企业及账号的
app_identifier "com.tww.test.enterprise" # 企业及账号app_idendifier
apple_id "2501046883@qq.com"" # 对应的账号的密码
end

三. Deliverfile文件修改

1.上传appstore的deliver文件

1
2
app_identifier "com.tww.test" # The bundle identifier of your app
username "2501046883@qq.com" # your Apple ID user

四. Fastfile文件修改

1.修改app identifier(就是bundle id,例如:com.husor.beibei)注意xcode7.0以上苹果改了CFBundleIdentifier or PRODUCT_BUNDLE_IDENTIFIER

1
2
3
4
5
update_app_identifier(
xcodeproj:PROJECT_FILE_PATH ,#project路径
plist_path:"#{PLIST_FILE_PATH}" ,#plist文件的路径
app_identifier:app_id
)

2.修改team(teamid)

1
2
3
4
5
6
7
def prepare_update_project_team(team_id)

	update_project_team(
path:PROJECT_FILE_PATH,
teamid: "K4W62VQT27"
)
end

3.修改info_plist(就是bundle id,例如:com.tww.test)

1
2
3
4
5
6
7
8
def prepare_update_info_plist(app_id)
update_info_plist(
xcodeproj:PROJECT_FILE_PATH ,
plist_path:"#{PLIST_FILE_PATH}" ,
app_identifier:app_id )
end

4.修改版本号和build号(修改为外部传入的版本,例如:1.0.0和100)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
def prepare_version(options)
#say 'version number:'
#say options[:version]
increment_version_number(
version_number: options[:version],
大专栏  Jenkins+Git+Fastlane+Fir CI集成an class="line"> xcodeproj: PROJECT_FILE_PATH,
) #say 'build number:'
#say options[:build]
increment_build_number(
build_number: options[:version],
xcodeproj: PROJECT_FILE_PATH,
)
end

5.修改签名的配置,配置对应的provision file,事先将个provisioning放入provision文件内容,关于怎么找到对应的provison可以通过xcode配置正确后,查看project文件(/Users/tianww/Library/MobileDevice/Provisioning Profiles/)找到后复制到这里。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
def prepare_version(options)
#say 'version number:'
#say options[:version]
increment_version_number(
version_number: options[:version],
xcodeproj: PROJECT_FILE_PATH,
) #say 'build number:'
#say options[:build]
increment_build_number(
build_number: options[:version],
xcodeproj: PROJECT_FILE_PATH,
)
end

6.编译打包为ipa使用gym,当然首先要安装gym。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
def generate_ipa(typePrefix,options,exportMethod,codeSignID)
#say 'generate ipa'
fullVersion = options[:version]
gym(
workspace: './BeiBeiAPP.xcworkspace',
configuration: "#{typePrefix}",
scheme: "#{SCHEME_NAME}",
output_directory: "./build",
output_name: "#{APP_NAME}.ipa",
archive_path: './build/',
clean: true,
codesigning_identity: "#{codeSignID}",
provisioning_profile_path: "./fastlane/provision/#{typePrefix}.mobileprovision",
include_symbols: 'true',
include_bitcode: 'false',
export_method: "#{exportMethod}"
)
end

或者使用shenzhen ,但是发现使用shenzhen比gym的要大

1
2
3
4
5
6
7
8
9
10
11
12
13
14
def generate_ipa(typePrefix,options,exportMethod,codeSignID)
#say 'generate ipa'
fullVersion = options[:version] + '.' + options[:build]
channelId = options[:channel_id]
ipa(
configuration: typePrefix,
scheme:"#{SCHEME_NAME}",
clean: true,
destination:"./build",
ipa:"#{APP_NAME}_#{fullVersion}_#{typePrefix}.ipa",
archive:false
) end

7.构建不同的lane,处理不同的包。

1
2
3
4
5
6
7
8
9
10
11
12
13
# 企业版 证书打包
desc "InHouse by personal apple account"
lane :InHouse do |options|
typePrefix = 'InHouse'
exportMethod = 'enterprise'
codeSigningIdentify = 'iPhone Distribution:tww'
prepare_version(options)
update_provision(typePrefix)
prepare_update_project_team('K4W62VQT27')
prepare_update_app_identifier("#{INHOUSE_IDENTIFIER}")
prepare_update_info_plist("#{INHOUSE_IDENTIFIER}")
generate_ipa(typePrefix,options,exportMethod,codeSigningIdentify)
end

参考

  • fastlane actions所有的actions的详细讲解。当然我们也可以在terminate中输入以下命令:

    1
    2
    fastlane actions(会列出所有的action)
    fastlane action deliver(单独详细的列出deliver的action对应的所有的内容)

Jenkins+Git+Fastlane+Fir CI集成的更多相关文章

  1. Jenkins +git +python 进行持续集成进行接口测试(接口测试jenkins持续集成篇)

    使用jenkins+git+python脚本进行持续集成的接口测试,在jenkins平台,利用插件等,把管理代码的git仓库的代码更新下来进行持续接口测试,python进行开发测试脚本,git进行远程 ...

  2. 环境部署(七):linux下Jenkins+Git+JDK持续集成

    前面几篇博客介绍了linux下安装Jenkins.Git.JDK以及Git基础教程和Git关联github等内容,这篇博客,介绍下如何在linux服务器中利用它们构建持续集成环境... 一.准备工作 ...

  3. Jenkins+GitHub+Xcode+fir搭了一个持续集成环境

    enkins+GitHub+Xcode+fir搭了一个持续集成环境 字数826 阅读5699 评论44 喜欢49 原文链接 Coding Duck 今天用Jenkins+GitHub+Xcode+fi ...

  4. 「持续集成实践系列」Jenkins 2.x 搭建CI需要掌握的硬核要点

    1. 前言 随着互联网软件行业快速发展,为了抢占市场先机,企业不得不持续提高软件的交付效率.特别是现在国内越来越多企业已经在逐步引入DevOps研发模式的变迁,在这些背景催促之下,对于企业研发团队所需 ...

  5. 「持续集成实践系列 」Jenkins 2.x 构建CI自动化流水线常见技巧

    在上一篇文章中,我们介绍了Jenkins 2.x实现流水线的两种语法,以及在实际工作中该如何选择脚本式语法或声明式语法.原文可查阅:「持续集成实践系列」Jenkins 2.x 搭建CI需要掌握的硬核要 ...

  6. jenkins + Git 搭建持续集成环境

    持续集成通过自动化构建.自动化测试以及自动化部署加上较高的集成频率保证了开发系统中的问题能迅速被发现和修复,降低了集成失败的风险,使得系统在开发中始终保持在一个稳定健康的集成状态.jenkins是目前 ...

  7. Jenkins+maven+git+sonar 系统持续集成&代码单測管理

    Jenkins+maven+git+sonar 系统持续集成&代码单測管理 Jenkins的安装 Jenkins是基于Java开发的一种持续集成工具,用于监控持续反复的工作.功能包含: 1.持 ...

  8. Jenkins+Git 持续集成

    持续集成是必要的! 希望达到的效果是:开发同事签入代码后,对应的站点可以自动实现更新.目前还只在在内部服务器上实现开发环境中的站点更新,不涉及到线上的发布. 目前使用Jenkins实现这样的持续集成. ...

  9. Linux下Jenkins+git+gradle持续集成环境搭建

    Linux下Jenkins+git+gradle持续集成环境搭建 来源:IT165收集  发布日期:2014-08-22 21:45:50 我来说两句(0)收藏本文   一.项目介绍 和 linux ...

随机推荐

  1. 五、Shell脚本高级编程实战第五部

    一.条件表达式 在bash的各种流程控制结构中通常要进行各种测试,然后根据测试结果执行不同的操作.有时也和if结合,让我们方便判断. test: 1)判断文件是否存在:test -f  file 2) ...

  2. 第04项目:淘淘商城(SpringMVC+Spring+Mybatis)【第十天】(单点登录系统实现)

    https://pan.baidu.com/s/1bptYGAb#list/path=%2F&parentPath=%2Fsharelink389619878-229862621083040 ...

  3. TPO1-3Timberline Vegetabtion on Mountain|have the advantage over

    The upper timberline, like the snow line, is highest in the tropics and lowest in the Polar Regions. ...

  4. Durandal入门

    参考:http://www.360doc.com/content/14/1223/11/13819_435123743.shtml 示例代码下载地址:http://durandaljs.com/ver ...

  5. oracle安装和使用

    1.0 安装 2.0 初始化 1.使用 sqlplus 连接oracle数据库 1)在cmd中输入sqlplus  /nolog 2)使用管理员账户登录orcl数据库实例 conn  sys/gzsx ...

  6. CCP 协议

    转载 1.  CCP协议概述 CCP(CAN Calibration Protocol)是一种基于CAN总线的匹配标定协议.ECU都需要经过匹配标定的过程,从而确定其运行参数和控制参数.有时为了实现对 ...

  7. [LC] 146. LRU Cache

    Design and implement a data structure for Least Recently Used (LRU) cache. It should support the fol ...

  8. 11)const

    const修饰一个  变量   为只读 : 然后 我再 a=: 这样写就是不行. 其实这个知识点主要考察    指针变量  指针指向的内存   是两个概念 char buf[]="dhasl ...

  9. day41-进程-管道

    #1.管道Pipe:双向通信: from multiprocessing import Pipe p1,p2 = Pipe() p1.send('hello') print(p2.recv()) p2 ...

  10. kettle的基本使用

    一.下载下载kettlehttp://sourceforge.net/projects/pentaho/files/Data%20Integration/7.0/pdi-ce-7.0.0.0-25.z ...