Class: FastlaneCore::AltoolTransporterExecutor
- Inherits:
-
TransporterExecutor
- Object
- TransporterExecutor
- FastlaneCore::AltoolTransporterExecutor
- Defined in:
- fastlane_core/lib/fastlane_core/itunes_transporter.rb
Overview
Generates commands and executes the altool.
Constant Summary
Constants inherited from TransporterExecutor
TransporterExecutor::ITMS_PROVIDER_REGEX
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
- #additional_upload_parameters ⇒ Object
- #build_credential_params(username = nil, password = nil, jwt = nil, api_key = nil) ⇒ Object
- #build_download_command(username, password, apple_id, destination = "/tmp", provider_short_name = "", jwt = nil) ⇒ Object
- #build_provider_ids_command(username, password, jwt = nil, api_key = nil) ⇒ Object
- #build_upload_command(username, password, source = "/tmp", options = {}) ⇒ Object
- #build_verify_command(username, password, source = "/tmp", options = {}) ⇒ Object
- #displayable_errors ⇒ Object
- #execute(command, hide_output) {|@all_lines| ... } ⇒ Object
- #handle_error(password) ⇒ Object
- #parse_provider_info(lines) ⇒ Object
Methods inherited from TransporterExecutor
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
262 263 264 |
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 262 def errors @errors end |
Instance Method Details
#additional_upload_parameters ⇒ Object
376 377 378 379 380 381 |
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 376 def additional_upload_parameters env_deliver_additional_params = ENV["DELIVER_ALTOOL_ADDITIONAL_UPLOAD_PARAMETERS"] return nil if env_deliver_additional_params.to_s.strip.empty? env_deliver_additional_params.to_s.strip end |
#build_credential_params(username = nil, password = nil, jwt = nil, api_key = nil) ⇒ Object
307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 307 def build_credential_params(username = nil, password = nil, jwt = nil, api_key = nil) if !username.nil? && !password.nil? && api_key.nil? "-u #{username.shellescape} -p #{password.shellescape}" elsif !api_key.nil? # Individual API keys have no issuer_id; altool requires --apiIssuer # to be present, so we pass the key_id as a placeholder and add # --api-key-subject user to signal individual key JWT generation. if api_key[:issuer_id] "--apiKey #{api_key[:key_id]} --apiIssuer #{api_key[:issuer_id]}" else "--apiKey #{api_key[:key_id]} --apiIssuer #{api_key[:key_id]} --api-key-subject user" end end end |
#build_download_command(username, password, apple_id, destination = "/tmp", provider_short_name = "", jwt = nil) ⇒ Object
354 355 356 |
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 354 def build_download_command(username, password, apple_id, destination = "/tmp", provider_short_name = "", jwt = nil) raise "This feature has not been implemented yet with altool for Xcode 14" end |
#build_provider_ids_command(username, password, jwt = nil, api_key = nil) ⇒ Object
343 344 345 346 347 348 349 350 351 352 |
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 343 def build_provider_ids_command(username, password, jwt = nil, api_key = nil) use_api_key = !api_key.nil? [ ("API_PRIVATE_KEYS_DIR=#{api_key[:key_dir]}" if use_api_key), "xcrun altool", "--list-providers", build_credential_params(username, password, jwt, api_key), "--output-format json" ].compact.join(' ') end |
#build_upload_command(username, password, source = "/tmp", options = {}) ⇒ Object
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 |
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 322 def build_upload_command(username, password, source = "/tmp", = {}) provider_short_name = .fetch(:provider_short_name, "") provider_public_id = .fetch(:provider_public_id, "") jwt = [:jwt] platform = [:platform] api_key = [:api_key] use_api_key = !api_key.nil? [ ("API_PRIVATE_KEYS_DIR=#{api_key[:key_dir]}" if use_api_key), "xcrun altool", "--upload-app", build_credential_params(username, password, jwt, api_key), ("--asc-provider #{provider_short_name}" unless use_api_key || provider_short_name.to_s.empty?), ("--provider-public-id #{provider_public_id}" unless use_api_key || provider_public_id.to_s.empty?), platform_option(platform), file_upload_option(source), additional_upload_parameters, "-k 100000" ].compact.join(' ') end |
#build_verify_command(username, password, source = "/tmp", options = {}) ⇒ Object
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 358 def build_verify_command(username, password, source = "/tmp", = {}) provider_short_name = .fetch(:provider_short_name, "") provider_public_id = .fetch(:provider_public_id, "") api_key = [:api_key] platform = [:platform] use_api_key = !api_key.nil? [ ("API_PRIVATE_KEYS_DIR=#{api_key[:key_dir]}" if use_api_key), "xcrun altool", "--validate-app", build_credential_params(username, password, nil, api_key), ("--asc-provider #{provider_short_name}" unless use_api_key || provider_short_name.to_s.empty?), ("--provider-public-id #{provider_public_id}" unless use_api_key || provider_public_id.to_s.empty?), platform_option(platform), file_upload_option(source) ].compact.join(' ') end |
#displayable_errors ⇒ Object
387 388 389 |
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 387 def displayable_errors @errors.map { |error| "[Application Loader Error Output]: #{error}" }.join("\n") end |
#execute(command, hide_output) {|@all_lines| ... } ⇒ Object
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 264 def execute(command, hide_output) if Helper.test? yield(nil) if block_given? return command end @errors = [] @all_lines = [] if hide_output # Show a one time message instead UI.success("Waiting for App Store Connect transporter to be finished.") UI.success("Application Loader progress... this might take a few minutes...") end begin exit_status = FastlaneCore::FastlanePty.spawn(command) do |command_stdout, command_stdin, pid| command_stdout.each do |line| @all_lines << line parse_line(line, hide_output) # this is where the parsing happens end end rescue => ex # FastlanePty adds exit_status on to StandardError so every error will have a status code exit_status = ex.exit_status @errors << ex.to_s end @errors << "The call to the altool completed with a non-zero exit status: #{exit_status}. This indicates a failure." unless exit_status.zero? @errors << "-1 indicates altool exited abnormally; try retrying (see https://github.com/fastlane/fastlane/issues/21535)" if exit_status == -1 unless @errors.empty? || @all_lines.empty? @all_lines.each do |line| UI.important("[altool] #{line}") end UI.("Application Loader output above ^") @errors.each { |error| UI.error(error) } end yield(@all_lines) if block_given? @errors.empty? end |
#handle_error(password) ⇒ Object
383 384 385 |
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 383 def handle_error(password) UI.error("Could not download/upload from App Store Connect!") end |
#parse_provider_info(lines) ⇒ Object
391 392 393 394 395 396 397 398 399 400 401 402 |
# File 'fastlane_core/lib/fastlane_core/itunes_transporter.rb', line 391 def parse_provider_info(lines) # This tries parsing the provider id from altool output to detect provider list provider_info = {} json_body = lines[-2] # altool outputs result in second line from last return provider_info if json_body.nil? providers = JSON.parse(json_body)["providers"] return provider_info if providers.nil? providers.each do |provider| provider_info[provider["ProviderName"]] = provider["ProviderShortname"] end provider_info end |