上次写了将 jenkins 集成 fastlane 打包 iOS 并将打包结果推送 slack,本次添加将打包生成的 ipa 推送 testflight,主要会借助 pilot 命令。
Testflight 当前已经被苹果公司收购并完善了功能,可以分发内测,作为提升 app 质量有很好的推动作用。
在安装好 fastlane 以后,其中的 pilot 命令可以查看一下它的参数:
pilot
The best way to manage your TestFlight testers and builds from your terminal
Commands:
add Adds new external tester(s) to a specific app (if given). This will also add an existing tester to an app.
builds Lists all builds for given application
distribute Distribute a previously uploaded binary to Apple TestFlight
export Exports all external testers to a CSV file
find Find tester(s) (internal or external) by their email address
help Display global or [command] help documentation
import Create external testers from a CSV file
list Lists all registered testers, both internal and external
remove Remove external tester(s) by their email address
upload Uploads a new binary to Apple TestFlight
Global Options:
-u, --username STRING Your Apple ID Username (PILOT_USERNAME)
-a, --app_identifier STRING The bundle identifier of the app to upload or manage testers (optional) (PILOT_APP_IDENTIFIER)
-i, --ipa STRING Path to the ipa file to upload (PILOT_IPA)
-w, --changelog STRING Provide the what's new text when uploading a new build (PILOT_CHANGELOG)
-d, --beta_app_description STRING Provide the beta app description when uploading a new build (PILOT_BETA_APP_DESCRIPTION)
-n, --beta_app_feedback_email STRING Provide the beta app email when uploading a new build (PILOT_BETA_APP_FEEDBACK)
-s, --skip_submission [VALUE] Skip the distributing action of pilot and only upload the ipa file (PILOT_SKIP_SUBMISSION)
-z, --skip_waiting_for_build_processing [VALUE] Don't wait for the build to process. If set to true, the changelog won't be set
(PILOT_SKIP_WAITING_FOR_BUILD_PROCESSING)
-x, --update_build_info_on_upload [VALUE] Update build info immediately after validation. This will set the changelog even if PILOT_SKIP_SUBMISSION is set, but
will have no effect if PILOT_SKIP_WAITING_FOR_BUILD_PROCESSING is set (PILOT_UPDATE_BUILD_INFO_ON_UPLOAD)
-p, --apple_id STRING The unique App ID provided by iTunes Connect (PILOT_APPLE_ID)
--distribute_external [VALUE] Should the build be distributed to external testers? (PILOT_DISTRIBUTE_EXTERNAL)
-f, --first_name STRING The tester's first name (PILOT_TESTER_FIRST_NAME)
-l, --last_name STRING The tester's last name (PILOT_TESTER_LAST_NAME)
-e, --email STRING The tester's email (PILOT_TESTER_EMAIL)
-c, --testers_file_path STRING Path to a CSV file of testers (PILOT_TESTERS_FILE)
可以看到 pilot 是最好的方式管理你的 TestFlight 测试人员和从终端构建的工具,注意:上传 TestFlight 的 ipa 必须打包方式是 appstore,且版本号应该为 3 位并高于已经在线上 Appstore 可以下载的版本。
我的上传脚本为:
#!/bin/bash
set -x
#计时
SECONDS=0
#假设脚本放置在与项目相同的路径下
project_path=$(pwd)
#取当前时间字符串添加到文件结尾
now=$(date +"%Y_%m_%d_%H_%M")
#取替换BundleVersion的时间字符串
now_date=$(date +"%Y%m%d%H%M")
#获取当前脚本路径
file_path=$(cd `dirname $0`; pwd)
#上传用户的username
username="xx"
#上传用户App id
apple_id="xx"
#bundleIdentifier
bundle_id="xxx"
#指定image和ipa最后路径
ipa_path="$project_path/xx.ipa"
#上传team_id
team_id="xxxx"
#上传team_name
team_name="xxx"
#上传dev_portal_team_id
dev_portal_team_id="xxx"
#上传itc_provider
itc_provider="xxx"
distribute_external=$1
changelog="xxxx"
beta_app_description="xxxx"
#反馈邮箱
email="xxxx"
group=$2
if [ -z "$2" ]; then
group="xxx"
fi
#执行上传testflight
pilot upload --verbose --username ${username} --app_identifier ${bundle_id}
--changelog ${changelog} -d ${beta_app_description}
--ipa ${ipa_path} --distribute_external ${distribute_external}
--apple_id ${apple_id} --team_id ${team_id}
--team_name "${team_name}" --dev_portal_team_id ${dev_portal_team_id}
--itc_provider "${itc_provider}" --beta_app_feedback_email "${email}" | exit
#输出总用时
echo "===Finished. Total time: ${SECONDS}s==="
脚本中的例如 team_id 等这些值,对于开发或者测试来说应该都不陌生,虽然脚本简单,但是能方便的上传 TestFlight,并且分发外部测试,真的非常方便。
最后集成到 jenkins,可以看到结果:
看到箭头指示的出现,代表已经成功的分发测试,可以去 Testflight app 下载安装新版本了。