Class: FastlaneCore::BuildWatcher

Inherits:
Object
  • Object
show all
Defined in:
fastlane_core/lib/fastlane_core/build_watcher.rb

Defined Under Namespace

Classes: VersionMatches

Class Method Summary collapse

Class Method Details

.wait_for_build_processing_to_be_complete(app_id: nil, platform: nil, train_version: nil, app_version: nil, build_version: nil, poll_interval: 10, timeout_duration: nil, strict_build_watch: false, return_when_build_appears: false, return_spaceship_testflight_build: true, select_latest: false, wait_for_build_beta_detail_processing: false) ⇒ Object

Returns The build we waited for. This method will always return a build.

Returns:

  • The build we waited for. This method will always return a build



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'fastlane_core/lib/fastlane_core/build_watcher.rb', line 14

def wait_for_build_processing_to_be_complete(app_id: nil, platform: nil, train_version: nil, app_version: nil, build_version: nil, poll_interval: 10, timeout_duration: nil, strict_build_watch: false, return_when_build_appears: false, return_spaceship_testflight_build: true, select_latest: false, wait_for_build_beta_detail_processing: false)
  # Warn about train_version being removed in the future
  if train_version
    UI.deprecated(":train_version is no longer a used argument on FastlaneCore::BuildWatcher. Please use :app_version instead.")
    app_version = train_version
  end

  # Warn about strict_build_watch being removed in the future
  if strict_build_watch
    UI.deprecated(":strict_build_watch is no longer a used argument on FastlaneCore::BuildWatcher.")
  end

  platform = Spaceship::ConnectAPI::Platform.map(platform) if platform
  UI.message("Waiting for processing on... app_id: #{app_id}, app_version: #{app_version}, build_version: #{build_version}, platform: #{platform}")

  build_watching_start_time = Time.new
  unless timeout_duration.nil?
    end_time = build_watching_start_time + timeout_duration
    UI.message("Will timeout watching build after #{timeout_duration} seconds around #{end_time}...")
  end

  showed_info = false
  loop do
    matched_build, app_version_queried = matching_build(watched_app_version: app_version, watched_build_version: build_version, app_id: app_id, platform: platform, select_latest: select_latest)

    if matched_build.nil? && !showed_info
      UI.important("Read more information on why this build isn't showing up yet - https://github.com/fastlane/fastlane/issues/14997")
      showed_info = true
    end

    report_status(build: matched_build, wait_for_build_beta_detail_processing: wait_for_build_beta_detail_processing)

    # Processing of builds by AppStoreConnect can be a very time consuming task and will
    # block the worker running this task until it is completed. In some cases,
    # having a build resource appear in AppStoreConnect (matched_build) may be enough (i.e. setting a changelog)
    # so here we may choose to skip the full processing of the build if return_when_build_appears is true
    if matched_build && (return_when_build_appears || processed?(build: matched_build, wait_for_build_beta_detail_processing: wait_for_build_beta_detail_processing))

      if !app_version.nil? && app_version != app_version_queried
        UI.important("App version is #{app_version} but build was found while querying #{app_version_queried}")
        UI.important("This shouldn't be an issue as Apple sees #{app_version} and #{app_version_queried} as equal")
        UI.important("See docs for more info - https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-102364")
      end

      if return_spaceship_testflight_build
        return matched_build.to_testflight_build
      else
        return matched_build
      end
    end

    # Before next poll, force stop build watching, if we exceeded the 'timeout_duration' waiting time
    force_stop_build_watching_if_required(start_time: build_watching_start_time, timeout_duration: timeout_duration)

    sleep(poll_interval)
  end
end