从零开始devops-fastlane配置


https://www.jianshu.com/p/db5fe7fed9f3
https://blog.csdn.net/l7022995/article/details/79321924
https://www.jianshu.com/p/840943eff17b

# 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

default_platform(:ios)

platform :ios do
  desc "Description of what the lane does"
    schemeName = "iOS_CI_Test"
    outputpath = "../output/#{schemeName}_dev"

    desc "Archive Dev"
    lane :dev do
      # update_project_provisioning(
      #    profile: "./provisions/wangyuhengtest.mobileprovision",
      #    build_configuration:"Debug")
     gym(scheme: schemeName,
       #没有workspace的话,使用 project: "#{schemeName}.xcodeproj" 替换下面??   
        workspace: "#{schemeName}.xcworkspace",
        export_method:"development",
        configuration: "Debug",
        output_directory: outputpath,
        silent: true)    
    end
    lane :adhoc do
      # update_project_provisioning(
      #    profile: "./provisions/wangyuhengtest.mobileprovision",
      #    build_configuration:"Debug")
     gym(scheme: schemeName,
       #没有workspace的话,使用 project: "#{schemeName}.xcodeproj" 替换下面??   
        workspace: "#{schemeName}.xcworkspace",
        export_method:"ad-hoc",
        configuration: "Release",
        output_directory: outputpath,
        silent: true)    
    end
  # lane :custom_lane do
  #   # add actions here: https://docs.fastlane.tools/actions

  # end
end

打包脚本

# You can define as many lanes as you want
desc "Deploy a new version to the App Store"
lane :release do |op|
increment_version_number(version_number: op[:version]) #根据入参version获取app版本号
increment_build_number(build_number: op[:version]) #将build号设置与app版本号相同


    # 设置app的info.plist文件项
    set_info_plist_value(path: "./xxx/Info.plist",  #info.plist文件目录
                        key: "UIFileSharingEnabled",  # key,将plist文件以Source Code形式打开可查询对应的key
                        value: false)  # value

    # 设置自定义plist文件项,用于给app配置不同的服务器URL
    set_info_plist_value(path: "./xxx/hostAddress.plist",
                        key: "host",
                        value: "https:/zhengshiServer:xx/xxx/xxx")

    # 设置某些服务是否有效
    # 还可以使用modify_services,具体参考官网相关文档
    produce(
        enable_services:{
            push_notification: "on",
       }
    )

    # 更新Provisioning Profile
    # 在项目当前目录下创建provisions文件夹,并将App Store版本的.mobileprovision文件保存在里面,名称随意。
    update_project_provisioning(profile: "./provisions/appstore.mobileprovision")

    # 更新项目团队
    update_project_team(path: "xxx.xcodeproj",
                  teamid: "5JC8GZ432G")

    # 开始打包
    gym(# use_legacy_build_api: true,  # Xcode 9之后,需要去掉
        output_name: "appstore",  # 输出的ipa名称
        silent: true,  # 隐藏没有必要的信息
        clean: true,  # 在构建前先clean
        configuration: "Release",  # 配置为Release版本
        codesigning_identity: "iPhone Distribution: xxx Co.,Ltd. (5JC8GZ432G)",  # 代码签名证书
        buildlog_path: "./fastlanelog",  # fastlane构建ipa的日志输出目录
        export_method: "app-store", # Xcode 9增加export_method标签
        output_directory: "/Users/xxx/Desktop")  # ipa输出目录

end
desc "Build a new version use the ceshi"
lane :ceshi do |op|
increment_version_number(version_number: op[:version])
increment_build_number(build_number: op[:version])


    set_info_plist_value(path: "./xxx/Info.plist",
                        key: "UIFileSharingEnabled",
                        value: true)

    set_info_plist_value(path: "./xxx/hostAddress.plist",
                        key: "host",
                        value: "https:/ceshiServer:xx/xxx/xxx")

    # 设置某些服务是否有效
    # 还可以使用modify_services,具体参考官网相关文档
    produce(
        enable_services:{
            push_notification: "off",
        }
    )

    # 将Development版本的.mobileprovision文件保存在里面,名称随意。
    update_project_provisioning(profile: "./provisions/development.mobileprovision")

    update_project_team(path: "xxx.xcodeproj",
                  teamid: "5JC8GZ432G")

    gym(# use_legacy_build_api: true,
        output_name: "ceshi",
        silent: true,
        clean: true,
        configuration: "Debug",
        buildlog_path: "./fastlanelog",
        codesigning_identity: "iPhone Developer: xxx (xxxxxxxxxx)",
        export_method: "development", # Xcode 9增加export_method标签
        output_directory: "/Users/xxx/Desktop"
  )
end

相关