iOS Jenkins+Fastlane 自动化打包

2019-09-29  本文已影响0人  聆听随风

今天本地搭建了下iOS自动化打包,参照博客 https://juejin.im/post/5d70d4c45188254a1619cf73,该博客已经说明很详细,在此感谢!

        根据这篇博客操作,fastlane 很顺利,操作Jenkins遇到了问题,问题原因是由于Fastlane中Appfile配置引起,但是通过Fastlane打包时没有遇到问题(不配置打包过程要在控制台输入username,即apple_id("[[APPLE_ID]]") # Your Apple email address,配置了在控制台就不用输入了)在此记录下问题。

1.  安装完后 Appfile 要修改配置,不修改fastlane打包没问题,但Jenkins打包时会出现问题,只修改这两项,把注释去掉,改成自己app信息

# app_identifier("[[APP_IDENTIFIER]]") # The bundle identifier of your app

# apple_id("[[APPLE_ID]]") # Your Apple email address

2. Jenkins打包过程,我配置比较简单,和博客有点区别。上传蒲公英是在Fastfile文件中配置的,参考的博客中有具体如何写脚本。

(1)新建item选择Freestyle project

(2) 具体配置只配置了一项内容即构建 Execute shell

(3)不设置Appfile文件构建失败

控制台输出的错误

Started by userhaomingleiRunning as SYSTEMBuilding in workspace /Users/hml/.jenkins/workspace/health[health] $ /bin/sh -xe /var/folders/r5/jmmmtrdd6019xhx7_jh2bcwr0000gn/T/jenkins7882491107169334358.sh+ cd /Users/hml/Desktop/SVN_Project/health+ fastlane topgyer_debug $'desc:�\213�\225'[14:17:22]: �[33mfastlane detected a Gemfile in the current directory�[0m[14:17:22]: �[33mhowever it seems like you don't use `bundle exec`�[0m[14:17:22]: �[33mto launch fastlane faster, please use�[0m[14:17:22]: [14:17:22]: �[36m$ bundle exec fastlane topgyer_debug desc:测试�[0m[14:17:22]: [14:17:22]: �[33mGet started using a Gemfile for fastlanehttps://docs.fastlane.tools/getting-started/ios/setup/#use-a-gemfile�[0m+-----------------------+---------+--------+| �[32mUsed plugins�[0m |+-----------------------+---------+--------+| Plugin | Version | Action |+-----------------------+---------+--------+| fastlane-plugin-pgyer | 0.2.2 | pgyer |+-----------------------+---------+--------+undefined method `username' for #undefined method `username' for #[14:17:23]: �[32m------------------------------�[0m[14:17:23]: �[32m--- Step: default_platform ---�[0m[14:17:23]: �[32m------------------------------�[0m[14:17:23]: �[32m----------------------------------�[0m[14:17:23]: �[32m--- Step: get_info_plist_value ---�[0m[14:17:23]: �[32m----------------------------------�[0m[14:17:23]: �[32m----------------------------------�[0m[14:17:23]: �[32m--- Step: get_info_plist_value ---�[0m[14:17:23]: �[32m----------------------------------�[0m[14:17:23]: �[32mDriving the lane 'ios topgyer_debug' 🚀�[0mundefined method `username' for #undefined method `username' for #[14:17:23]: ************| 开始打包.ipa 文件... |************undefined method `username' for #undefined method `username' for #[14:17:23]: �[32m----------------------------------�[0m[14:17:23]: �[32m--- Step: get_info_plist_value ---�[0m[14:17:23]: �[32m----------------------------------�[0mundefined method `username' for #undefined method `username' for #[14:17:23]: *************| 更新build 20190919.11 |*************undefined method `username' for #undefined method `username' for #[14:17:23]: �[32m------------------------------------�[0m[14:17:23]: �[32m--- Step: increment_build_number ---�[0m[14:17:23]: �[32m------------------------------------�[0mCurrent version of project health is: 20190919.10/Users/hml/Desktop/SVN_Project/health[14:17:24]: �[36m$ cd /Users/hml/Desktop/SVN_Project/health && agvtool new-version -all 20190919.11 && cd -�[0m[14:17:24]: ▸ �[35mSetting version of project health to:�[0m[14:17:24]: ▸ �[35m20190919.11.�[0m[14:17:24]: ▸ �[35mAlso setting CFBundleVersion key (assuming it exists)�[0m[14:17:24]: ▸ �[35mUpdating CFBundleVersion in Info.plist(s)...�[0m[14:17:24]: ▸ �[35mUpdated CFBundleVersion in "health.xcodeproj/../health/Info.plist" to 20190919.11�[0m[14:17:24]: ▸ �[35m/Users/hml/Desktop/SVN_Project/health�[0m[14:17:24]: �[32m------------------�[0m[14:17:24]: �[32m--- Step: cert ---�[0m[14:17:24]: �[32m------------------�[0mundefined method `username' for #undefined method `username' for #undefined method `username' for #undefined method `username' for #undefined method `username' for #undefined method `username' for #undefined method `username' for #undefined method `username' for #+---------------+------------------------------------------------+| �[32mSummary for cert 2.131.0�[0m |+---------------+------------------------------------------------+| development | false || force | false || keychain_path | /Users/hml/Library/Keychains/login.keychain-db || platform | ios |+---------------+------------------------------------------------++-----------------------------------+-------------------+| �[33mLane Context�[0m |+-----------------------------------+-------------------+| DEFAULT_PLATFORM | ios || GET_INFO_PLIST_VALUE_CUSTOM_VALUE | 20190919.10 || PLATFORM_NAME | ios || LANE_NAME | ios topgyer_debug || BUILD_NUMBER | 20190919.11 |+-----------------------------------+-------------------+[14:17:24]: �[31mNo value found for 'username'�[0m+------+------------------------+-------------+| �[32mfastlane summary�[0m |+------+------------------------+-------------+| Step | Action | Time (in s) |+------+------------------------+-------------+| 1 | default_platform | 0 || 2 | get_info_plist_value | 0 || 3 | get_info_plist_value | 0 || 4 | get_info_plist_value | 0 || 5 | increment_build_number | 0 || 💥 | �[31mcert�[0m | 0 |+------+------------------------+-------------+[14:17:24]: �[31mfastlane finished with errors�[0m�[31m[!] No value found for 'username'�[0mBuild step 'Execute shell' marked build as failureFinished: FAILURE

(4)设置Appfile后构建成功

上一篇下一篇

猜你喜欢

热点阅读