|
上次写了将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可以下载的版本。
我的上传脚本为:
- <span class="c">#!/bin/bash</span>
- <span class="nb">set</span> -x
- <span class="c">#计时</span>
- <span class="nv">SECONDS</span><span class="o">=</span>0
- <span class="c">#假设脚本放置在与项目相同的路径下</span>
- <span class="nv">project_path</span><span class="o">=</span><span class="k">$(</span><span class="nb">pwd</span><span class="k">)</span>
- <span class="c">#取当前时间字符串添加到文件结尾</span>
- <span class="nv">now</span><span class="o">=</span><span class="k">$(</span>date +<span class="s2">"%Y_%m_%d_%H_%M"</span><span class="k">)</span>
- <span class="c">#取替换BundleVersion的时间字符串</span>
- <span class="nv">now_date</span><span class="o">=</span><span class="k">$(</span>date +<span class="s2">"%Y%m%d%H%M"</span><span class="k">)</span>
- <span class="c">#获取当前脚本路径</span>
- <span class="nv">file_path</span><span class="o">=</span><span class="k">$(</span><span class="nb">cd</span> <span class="sb">`</span>dirname <span class="nv">$0</span><span class="sb">`</span>; <span class="nb">pwd</span><span class="k">)</span>
- <span class="c">#上传用户的username</span>
- <span class="nv">username</span><span class="o">=</span><span class="s2">"xx"</span>
- <span class="c">#上传用户App id</span>
- <span class="nv">apple_id</span><span class="o">=</span><span class="s2">"xx"</span>
- <span class="c">#bundleIdentifier</span>
- <span class="nv">bundle_id</span><span class="o">=</span><span class="s2">"xxx"</span>
- <span class="c">#指定image和ipa最后路径</span>
- <span class="nv">ipa_path</span><span class="o">=</span><span class="s2">"</span><span class="nv">$project_path</span><span class="s2">/xx.ipa"</span>
- <span class="c">#上传team_id</span>
- <span class="nv">team_id</span><span class="o">=</span><span class="s2">"xxxx"</span>
- <span class="c">#上传team_name</span>
- <span class="nv">team_name</span><span class="o">=</span><span class="s2">"xxx"</span>
- <span class="c">#上传dev_portal_team_id</span>
- <span class="nv">dev_portal_team_id</span><span class="o">=</span><span class="s2">"xxx"</span>
- <span class="c">#上传itc_provider</span>
- <span class="nv">itc_provider</span><span class="o">=</span><span class="s2">"xxx"</span>
- <span class="nv">distribute_external</span><span class="o">=</span><span class="nv">$1</span>
- <span class="nv">changelog</span><span class="o">=</span><span class="s2">"xxxx"</span>
- <span class="nv">beta_app_description</span><span class="o">=</span><span class="s2">"xxxx"</span>
- <span class="c">#反馈邮箱</span>
- <span class="nv">email</span><span class="o">=</span><span class="s2">"xxxx"</span>
- <span class="nv">group</span><span class="o">=</span><span class="nv">$2</span>
- <span class="k">if</span> <span class="o">[</span> -z <span class="s2">"</span><span class="nv">$2</span><span class="s2">"</span> <span class="o">]</span>; <span class="k">then
- </span><span class="nv">group</span><span class="o">=</span><span class="s2">"xxx"</span>
- <span class="k">fi</span>
- <span class="c">#执行上传testflight</span>
- pilot upload --verbose --username <span class="k">${</span><span class="nv">username</span><span class="k">}</span> --app_identifier <span class="k">${</span><span class="nv">bundle_id</span><span class="k">}</span>
- --changelog <span class="k">${</span><span class="nv">changelog</span><span class="k">}</span> -d <span class="k">${</span><span class="nv">beta_app_description</span><span class="k">}</span>
- --ipa <span class="k">${</span><span class="nv">ipa_path</span><span class="k">}</span> --distribute_external <span class="k">${</span><span class="nv">distribute_external</span><span class="k">}</span>
- --apple_id <span class="k">${</span><span class="nv">apple_id</span><span class="k">}</span> --team_id <span class="k">${</span><span class="nv">team_id</span><span class="k">}</span>
- --team_name <span class="s2">"</span><span class="k">${</span><span class="nv">team_name</span><span class="k">}</span><span class="s2">"</span> --dev_portal_team_id <span class="k">${</span><span class="nv">dev_portal_team_id</span><span class="k">}</span>
- --itc_provider <span class="s2">"</span><span class="k">${</span><span class="nv">itc_provider</span><span class="k">}</span><span class="s2">"</span> --beta_app_feedback_email <span class="s2">"</span><span class="k">${</span><span class="nv">email</span><span class="k">}</span><span class="s2">"</span> | <span class="nb">exit</span>
- <span class="c">#输出总用时</span>
- <span class="nb">echo</span> <span class="s2">"===Finished. Total time: </span><span class="k">${</span><span class="nv">SECONDS</span><span class="k">}</span><span class="s2">s==="</span>
复制代码 脚本中的例如team_id等这些值,对于开发或者测试来说应该都不陌生,虽然脚本简单,但是能方便的上传TestFlight,并且分发外部测试,真的非常方便。
最后集成到jenkins,可以看到结果:
看到箭头指示的出现,代表已经成功的分发测试,可以去Testflight app下载安装新版本了。
|
|