上一篇有讲关于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. [Algo] 223. Add Two Numbers

    You are given two linked lists representing two non-negative numbers. The digits are stored in rever ...

  2. tp3中子查询 逻辑条件是or

    直接用写sql最快 $map['_string'] = 'status=1 AND score>10'; //子查询条件字段不同 $condition['platform'] = 'swap'; ...

  3. 三十、sersync高级同步工具实时数据同步架构

    一.项目介绍 Sersync项目利用inotity与rsync技术实现对服务器数据实时同步的解决方案,其中inotity用于监控sersync所在服务器上的文件变化. Sersync项目的优点: 1. ...

  4. 5)void万能指针

    函数参数为空,定义函数时,可以使用void来修饰:int fun(void) 函数没有返回值:void fun(void) 不同定义void类型的普通变量:void a     //原因是,无法确定类 ...

  5. vue2.0学习之组件间通信

    /* child.vue*/ 子组件 <template> <div> /*必须要用div包裹起来,然后在里面写需要的组件内容,这里面和平常写的html是一样的*/ <d ...

  6. [LC] 127. Word Ladder

    Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest t ...

  7. Computing Essentials_第一章习题

  8. 利用git上传文件到github

    git add 文件名称/. "."代表全部 git commit -m -a git push -u origin master 推送到远程仓库 ---------------- ...

  9. mpvue框架的小程序和H5同时开发

    demo链接1.样式统一为了达到共用一套样式,采用px2rem-loader和px2rpx-loader进行代码的打包,细节如下: 由于UI设计图是在蓝湖上标注,宽度750,选择像素 PX 样式中直接 ...

  10. 7)加了基础控制器Controller.php

    文件目录展示: 改动代码展示: Controller.php <?php /** * Created by PhpStorm. * User: Interact * Date: 2017/8/2 ...