CLI for'fastlane' - The easiest way to automate building and releasing your iOS and Android apps
Run using `fastlane [platform] [lane_name]` To pass values to the lanes use `fastlane [platform] [lane_name] key:value key2:value2`
Commands: action Shows more information for a specific command actions Lists all available fastlane actions add_plugin Add a new plugin to your fastlane setup disable_crash_reporting Deprecated: fastlane doesn't use a crash reporter any more docs Generate a markdown based documentation based on the Fastfile enable_auto_complete Enable tab auto completion enable_crash_reporting Deprecated: fastlane doesn't use a crash reporter any more help Display global or [command] help documentation init Helps you with your initial fastlane setup install_plugins Install all plugins for this project lanes Lists all available lanes and shows their description list Lists all available lanes without description new_action Create a new custom action for fastlane. new_plugin Create a new plugin that can be used with fastlane run Run a fastlane one-off action without a full lane search_plugins Search for plugins, search query is optional trigger Run a sepcific lane. Pass the lane name and optionally the platform first. update_plugins Update all plugin dependencies
Global Options: --verbose -h, --help Display help documentation -v, --version Display version information
Author: Felix Krause <fastlane@krausefx.com>
Website: https://fastlane.tools
GitHub: https://github.com/fastlane/fastlane
我会随着下面每个概念的解释和展开来配合上面的命令一起讲解。
生命周期
执行顺序
方法名
说明
1
before_all
在执行 lane 之前只执行一次
2
before_each
每次执行 lane 之前都会执行一次
3
lane
自定义的任务
4
after_each
每次执行 lane 之后都会执行一次
5
after_all
在执行 lane 成功结束之后执行一次
6
error
在执行上述情况任意环境报错都会中止并执行一次
以上的部分大家在上一篇已经见识过了,有些还没接触到,不用着急都会一一说明。
任务(lane)
正常情况下你可能只会是用到一种任务方法 lane 但其实它会包含很多中高级用法。在文章的末尾会详细描述。
lane 其实可以理解为 def 的别名,因此多个 lane 的话实际上是可以相互调用的,这个其实特别实用,这样其实我就可以把 cocoapods 的执行放到单独的 lane 里面而不是 before_all,这样执行非构建的任务就不会执行不相关的任务或动作,因此 fastlane 而产生了一个私有任务用内部使用 private_lane
$ fastlane actions +--------------------+-------------------------------------------------------------+------------------+ | Available fastlane actions | +--------------------+-------------------------------------------------------------+------------------+ | Action | Description | Author | +--------------------+-------------------------------------------------------------+------------------+ | adb | Run ADB Actions | hjanuschka | | adb_devices | Get an Array of Connected android device serials | hjanuschka | | add_git_tag | This will add an annotated git tag to the current branch | Multiple | ... +--------------------+-------------------------------------------------------------+------------------+ Total of 175 actions
Get more information for one specific action using `fastlane action [name]`
+---------------------------------+ | adb | +---------------------------------+ | Run ADB Actions | | | | see adb --help for more details | | | | Created by hjanuschka | +---------------------------------+
+----------+----------------------------------------------------------------------+-------------------+---------+ | adb Options | +----------+----------------------------------------------------------------------+-------------------+---------+ | Key | Description | Env Var | Default | +----------+----------------------------------------------------------------------+-------------------+---------+ | serial | Android serial, which device should be used for this command | FL_ANDROID_SERIAL | | | command | All commands you want to pass to the adb command, e.g. `kill-server` | FL_ADB_COMMAND | | | adb_path | The path to your `adb` binary | FL_ADB_PATH | adb | +----------+----------------------------------------------------------------------+-------------------+---------+
+-------------------------------+ | adb Return Value | +-------------------------------+ | The output of the adb command | +-------------------------------+
More information can be found on https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Actions.md
$ fastlane new_action Must be lower case, and use a '_' between words. Do not use '.' examples: 'testflight', 'upload_to_s3' Name of your action: hello [15:33:15]: Created new action file './fastlane/actions/hello.rb'. Edit it to implement your custom action.
$ fastlane search_plugins [16:04:33]: Listing all available fastlane plugins
+--------------------------+---------------------------------------------------+-----------+ | Available fastlane plugins | +--------------------------+---------------------------------------------------+-----------+ | Name | Description | Downloads | +--------------------------+---------------------------------------------------+-----------+ | ruby | Useful fastlane actions for Ruby projects | 782 | | versioning | Allows to work set/get app version directly | 758 | | | to/from Info.plist | | | branding | Add some branding to your fastlane output | 716 | | instrumented_tests | New action to run instrumented tests for android. | 590 | | | This basically creates and boots an emulator | | | | before running an gradle commands so that you can | | | | run instrumented tests against that emulator. | | | | After the gradle command is executed, the avd | | | | gets shut down and deleted. This is really | | | | helpful on CI services, keeping them clean and | | | | always having a fresh avd for testing. | | | xamarin_build | Build xamarin android\ios projects | 582 | | appicon | Generate required icon sizes and iconset from a | 509 | | | master application icon. | | ... | download_file | This action downloads a file from an HTTP/HTTPS | 171 | | | url (e.g. ZIP file) and puts it in a destination | | | | path | | +--------------------------+---------------------------------------------------+-----------+
# 添加 sentry 插件 $ fastlane add_plugin sentry [16:16:23]: Plugin 'fastlane-plugin-sentry' was added to './fastlane/Pluginfile' [16:16:23]: It looks like fastlane plugins are not yet set up for this project. [16:16:23]: fastlane will create a new Gemfile at path 'Gemfile' [16:16:23]: This change is neccessary for fastlane plugins to work Should fastlane modify the Gemfile at path 'Gemfile'for you? (y/n) y [16:16:29]: Successfully modified 'Gemfile' [16:16:29]: Make sure to commit your Gemfile, Gemfile.lock and Pluginfile to version control Installing plugin dependencies... Successfully installed plugins
$ cat fastlane/Pluginfile # Autogenerated by fastlane # # Ensure this file is checked in to source control!