Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Continuous Integration with fastlane

Avatar for MWFire MWFire
December 14, 2017

Continuous Integration with fastlane

Supercharge iOS development and deployment with fastlane & Jenkins

Avatar for MWFire

MWFire

December 14, 2017

Other Decks in Programming

Transcript

  1. CERTIFICATES desc "Creates provisioning profiles for all configurations" lane :certs

    do match(app_identifier: IDENTIFIER, force: true, type: "development") match(app_identifier: IDENTIFIER, force: true, type: "adhoc") match(app_identifier: IDENTIFIER, force: true, type: "appstore") end
  2. PUSH NOTIFICATION CERTIFICATES desc "Creates push notification certificates" lane :apns_certs

    do pem( app_identifier: IDENTIFIER, pem_name: APNS_NAME, output_path: "apns_certs/", username: USERNAME ) end
  3. VERSION & CHANGELOG desc "Sets the build number to the

    current date, hour and minute" lane :set_build_number do build_number = Time.new.strftime("%m%d%H%M") increment_build_number build_number: build_number end desc "Sets the version number to the latest specified in changelog" lane :set_version_number do # Read the changelog and get topmost version number # Stolen from artsy/eidolon readme = File.read("../CHANGELOG.md") latest_version = readme.split("\n## ").first first_line = latest_version.split("\n").first version_number = first_line.split(" ")[1] increment_version_number version_number: version_number end
  4. UNIT TESTS esc "Runs the unit tests for the given

    configuration" desc "- param: config:debug|adhoc|release" lane :test do |options| # Jenkins setup setup_jenkins(result_bundle: false) # Clear derived data clear_derived_data # Get the configuration configuration = to_configuration(options[:config]) # Run unit tests on all test devices scan( scheme: SCHEME, workspace: WORKSPACE_NAME, devices: TEST_DEVICES, configuration: configuration, code_coverage: true )
  5. UNIT TESTS # Create a code coverage report slather( html:

    true, output_directory: "codecoverage", proj: PROJECT_NAME, workspace: WORKSPACE_NAME, scheme: SCHEME, ignore:[ "zooplusTests/*", "zooplusUITests/*", "Pods/*" ] ) end
  6. HOCKEY DISTRIBUTION desc "Creates AdHoc builds and uploads them to

    Hockey" lane :hockey_distribute do clear_derived_data ensure_git_status_clean set_version_number set_build_number commit_version_bump badge(shield: "V-#{get_version_number}.#{get_build_number}-blue", no_badge: false)
  7. HOCKEY DISTRIBUTION # Create the adhoc build gym( scheme: SCHEME,

    workspace: WORKSPACE_NAME, clean: true, configuration: "AdHoc", export_method: "ad-hoc", output_directory: "Builds" ) changelog = File.read("../CHANGELOG.md") hockey( api_token: HOCKEY_API_TOKEN, ipa: "Builds/zooplus.ipa", notes: changelog ) # Reset the repo, app icons will keep the badges otherwise reset_git_repo(force: true) end
  8. SNAPFILE devices([ "iPhone 8", "iPhone 8 Plus", "iPhone X", "iPhone

    SE", "iPad Pro (12.9-inch) (2nd generation)", # "iPhone 4s", - there's a bug on fastlane for 4s and Xcode 9 # "iPad Pro (10.5-inch)" there's a one pixel off bug ]) languages([ "de-DE", "en-GB", "en-US", "es-ES", "fr-FR", "nl-NL", "pt-PT", ["da", "da-DK"], ["fi", "fi-FI"], ["el", "el-GR"], ["it", "it-IT"], ["no", "nn-NO"], ["ru", "ru-RU"], ["sv", "sv-SE"] ]) # The name of the scheme which contains the UI Tests scheme "zooplusUITests"
  9. FASTFILE desc "Creates screenshots for all domains and devices" lane

    :screenshots do clear_derived_data snapshot( number_of_retries: 3, concurrent_simulators: true ) end
  10. MANAGING LOCALIZATIONS desc "Exports the dev language .xliff to POEditor"

    lane :update_translations do exclude_keys = [ "CFBundleName", "CFBundleShortVersionString" ] update_localizations( api_token: "XXXXXXXXXXX", project_id: "XXXXX", development_language: "en", exclude_keys: exclude_keys ) end
  11. MANAGING LOCALIZATIONS desc "Downloads and implements .xliff translations from POEditor"

    lane :import_translations do language_aliases = { "cs" => "cs-CZ", "da" => "da-DK", "sv" => "sv-SE", "no" => "nn", "pt" => "pt-PT", "hu" => "hu-HU", "ru" => "ru-RU", "es" => "es-ES", } import_localizations( api_token: "XXXXXXXXXXX", project_id: "XXXXX", output_path: "translations", development_language: "en", language_aliases: language_aliases ) end
  12. DEPLOY lane :deploy do |options| setup_jenkins(result_bundle: false) clear_derived_data ensure_git_status_clean set_version_number

    set_build_number commit_version_bump match(app_identifier: IDENTIFIER, force: true, type: "appstore")
  13. DEPLOY # Run tests scan( scheme: SCHEME, workspace: WORKSPACE_NAME, devices:

    ["iPhone 6s", "iPhone X"], configuration: "Release" ) # Build release version of app gym( scheme: SCHEME, workspace: WORKSPACE_NAME, clean: true, configuration: "Release", export_method: "app-store", output_directory: "Builds" ) # Submit app deliver( username: USERNAME, skip_metadata: true, skip_screenshots: !options[:upload_screenshots] == true, force: true ) end
  14. # Make sure Fastlane kills and opens simulators explicitly ENV['FASTLANE_EXPLICIT_OPEN_SIMULATOR']

    = "2" # This disables Aspera and Sigliants to upload the app # and guarantees upload through 443 TCP Port ENV["DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS"] = "-t DAV"
  15. WHY JENKINS? ▸ Free, Fast ( & Furious ) ▸

    Runs on your machine ▸ Easy to setup ▸ Extendable ▸ Huge community