Mac下,iOS jenkins + fastlane +三方托

2018-09-29  本文已影响55人  yiangdea

关于Jenkins安装请看: https://www.jianshu.com/p/41ecb06ae95f#
关于fastlane的流程请看: https://www.jianshu.com/p/7b73eef0d140

可持续化集成的步骤:

遇到的坑:

没有加载rvm 和 ruby, command not found报错。

Jenkins在启动构建的时候,没有配置当前的环境变量,PATH
导致ruby没有加载,很多库找不到,尤其是fastlane
这个时候就需要在本机上登陆command line
执行echo $PATH,将其复制,配置到Jenkins管理页面中,子节点下: key为PATH,value为echo $PATH的结果

钥匙串权限报错

security unlock-keychain -p edu100 login.keychain-db
security set-keychain-settings -t 3600 -l ~/Library/Keychains/login.keychain-db

最后奉上fastlane的脚本:

# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
#     https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
#     https://docs.fastlane.tools/plugins/available-plugins
#

# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane

# 解决 xcodebuild -showBuildSettings timed-out after 10 seconds and 3 retries. You can override the timeout value with the environment variable FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT, 
# and the number of retries with the environment variable FASTLANE_XCODEBUILD_SETTINGS_RETRIES
ENV["FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT"] = "180"
ENV["FASTLANE_XCODE_LIST_TIMEOUT"] = "180"


default_platform :ios

platform :ios do
  before_all do
  # ENV["SLACK_URL"] = "https://hooks.slack.com/services/..."
  match
  end

  desc "Runs all the tests"
  lane :test do
    
  end

  desc "提交一个新的Beta版本到 firim"
  lane :young_develop do
    
    # 版本build自增
    increment_build_number

    # 证书和配置文件管理工具
    # match
    
    # 用于导出archive的方法。有效值是:appstore, ad-hoc, package, enterprise, development, developer-id
    ipa_name = "young_jenkins-#{Time.new.strftime("%Y%m%d-%h%M")}"
    build_ios_app(
        export_method: development, 
        output_name: ipa_name, 
        scheme: young
    )

    # 上传Fir
    firim(
        firim_api_token: "4f2d5738a05d7a0cfd7dd7ac69b40436", 
        ipa: ipa_name
    )

end

  #执行lane成功后的回调
  after_all do |lane|
    # slack(
    #    message: "Successfully deployed new App Update."
    # )
  end

  # 如果流程发生异常会走这里并终止
  error do |lane, exception|
    # slack(
    #   message: exception.message,
    #   success: false
    # )
  end
end
上一篇 下一篇

猜你喜欢

热点阅读