Class: FastlaneCore::TransporterExecutor

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

Overview

Base class for executing the iTMSTransporter

Instance Method Summary collapse

Instance Method Details

#execute(command, hide_output) ⇒ Object



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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 33

def execute(command, hide_output)
  return command if Helper.test?

  # Workaround because the traditional transporter broke on 1st March 2018
  # More information https://github.com/fastlane/fastlane/issues/11958
  # As there was no communication from Apple, we don't know if this is a temporary
  # server outage, or something they changed without giving a heads-up
  if ENV["DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS"].to_s.length == 0
    ENV["DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS"] = "-t DAV"
  end

  @errors = []
  @warnings = []
  @all_lines = []

  if hide_output
    # Show a one time message instead
    UI.success("Waiting for iTunes Connect transporter to be finished.")
    UI.success("iTunes Transporter progress... this might take a few minutes...")
  end

  begin
    FastlaneCore::FastlanePty.spawn(command) do |command_stdout, command_stdin, pid|
      begin
        command_stdout.each do |line|
          @all_lines << line
          parse_line(line, hide_output) # this is where the parsing happens
        end
      rescue Errno::EIO
        # Exception ignored intentionally.
        # https://stackoverflow.com/questions/10238298/ruby-on-linux-pty-goes-away-without-eof-raises-errnoeio
      ensure
        Process.wait(pid)
      end
    end
  rescue => ex
    @errors << ex.to_s
  end

  exit_status = $?.exitstatus
  unless exit_status.zero?
    @errors << "The call to the iTMSTransporter completed with a non-zero exit status: #{exit_status}. This indicates a failure."
  end

  if @warnings.count > 0
    UI.important(@warnings.join("\n"))
  end

  if @errors.join("").include?("app-specific")
    raise TransporterRequiresApplicationSpecificPasswordError
  end

  if @errors.count > 0 && @all_lines.count > 0
    # Print out the last 15 lines, this is key for non-verbose mode
    @all_lines.last(15).each do |line|
      UI.important("[iTMSTransporter] #{line}")
    end
    UI.message("iTunes Transporter output above ^")
    UI.error(@errors.join("\n"))
  end

  # this is to handle GitHub issue #1896, which occurs when an
  #  iTMSTransporter file transfer fails; iTMSTransporter will log an error
  #  but will then retry; if that retry is successful, we will see the error
  #  logged, but since the status code is zero, we want to return success
  if @errors.count > 0 && exit_status.zero?
    UI.important("Although errors occurred during execution of iTMSTransporter, it returned success status.")
  end

  exit_status.zero?
end