美文网首页
Mac下,iOS jenkins + fastlane +三方托

Mac下,iOS jenkins + fastlane +三方托

作者: yiangdea | 来源:发表于2018-09-29 20:14 被阅读55次

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

可持续化集成的步骤:

  • Jenkins作为构建服务运行在服务器上
  • gitlab或其他服务器作为代码源(构建触发器控制)
  • Jenkins将代码载入服务器的运行目录下(workspace)
  • 运行Jenkins构建步骤(主要为执行shell),此部分主要是环境切换、静态分析和测试脚本执行、以及构建脚本执行等,这一部分fastlane可以作为主力军,大大简化构建的步骤。
  • Jenkins构建后的操作(多数为归档、邮件通知等)

遇到的坑:

没有加载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

相关文章

网友评论

      本文标题:Mac下,iOS jenkins + fastlane +三方托

      本文链接:https://www.haomeiwen.com/subject/sxgsoftx.html