上一篇有讲关于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. 01 - CentOS 中安装Python 2.7.16

    准备 下载链接:https://www.python.org/ftp/python/ 下载源码:wget https://www.python.org/ftp/python/2.7.16/Python ...

  2. day06-初识Vuetify框架UI框架和使用域名访问本地项目

    本项目的笔记和资料的Download,请点击这一句话自行获取. day01-springboot(理论篇) :day01-springboot(实践篇) day02-springcloud(理论篇一) ...

  3. 树莓派docker搭建

    树莓派上 Docker 的安装和使用 Docker 是一个开源的应用容器引擎,可以让开发者打包他们的应用以及依赖包到一个轻量级.可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟 ...

  4. jQuery篇

    jQuery 1.为什么使用jQuery? js中window onload事件只能出现一次,如果出现多次,后面的事件会覆盖掉前面的事件 js代码容错差 简单的动画效果实现很繁琐,例如简单的动画渐变效 ...

  5. 菜鸟cmake使用

    cmake是用过把源码生成visual studio 工程的工具,也就是生成.sln文件.他会把相应的库依赖都自动添加上. cmake有个CMakeLists.txt (具体语法这里先不介绍) 我都是 ...

  6. Durandal入门

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

  7. SGD/BGD/MBGD使用python简单实现

    算法具体可以参照其他的博客: 随机梯度下降: # coding=utf-8 ''' 随机梯度下降 ''' import numpy as np # 构造训练数据 x = np.arange(0., 1 ...

  8. Android drawable 加载效果

    <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:ones ...

  9. 九成AI企业亏损,人工智能商业落地为何这么难?

    自1956年"人工智能"一词诞生于"达特茅斯会议"后,前者就始终在不断向前推进.虽然中间经历了不少低谷和寒潮,但总算挺了过来.60多年后,人工智能在当下呈现突飞 ...

  10. [LC] 95. Unique Binary Search Trees II

    Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1 ...