Class: Fastlane::Actions::FirebaseAppDistributionAddTestersAction

Inherits:
Action
  • Object
show all
Extended by:
Fastlane::Auth::FirebaseAppDistributionAuthClient, Helper::FirebaseAppDistributionHelper
Defined in:
lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_add_testers_action.rb

Constant Summary

Constants included from Fastlane::Auth::FirebaseAppDistributionAuthClient

Fastlane::Auth::FirebaseAppDistributionAuthClient::CLIENT_ID, Fastlane::Auth::FirebaseAppDistributionAuthClient::CLIENT_SECRET, Fastlane::Auth::FirebaseAppDistributionAuthClient::REDACTION_CHARACTER, Fastlane::Auth::FirebaseAppDistributionAuthClient::REDACTION_EXPOSED_LENGTH, Fastlane::Auth::FirebaseAppDistributionAuthClient::SCOPE, Fastlane::Auth::FirebaseAppDistributionAuthClient::TOKEN_CREDENTIAL_URI

Class Method Summary collapse

Methods included from Fastlane::Auth::FirebaseAppDistributionAuthClient

fetch_auth_token

Methods included from Helper::FirebaseAppDistributionHelper

app_name_from_app_id, binary_type_from_path, blank?, get_ios_app_id_from_archive_plist, get_value_from_value_or_file, parse_plist, present?, string_to_array

Class Method Details

.authorsObject



48
49
50
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_add_testers_action.rb', line 48

def self.authors
  ["Tunde Agboola"]
end

.available_optionsObject



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
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_add_testers_action.rb', line 57

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :project_number,
                                env_name: "FIREBASEAPPDISTRO_PROJECT_NUMBER",
                                description: "Your Firebase project number. You can find the project number in the Firebase console, on the General Settings page",
                                type: Integer,
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :emails,
                                env_name: "FIREBASEAPPDISTRO_ADD_TESTERS_EMAILS",
                                description: "Comma separated list of tester emails to be created. A maximum of 1000 testers can be created at a time",
                                optional: true,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :file,
                                env_name: "FIREBASEAPPDISTRO_ADD_TESTERS_FILE",
                                description: "Path to a file containing a comma separated list of tester emails to be created. A maximum of 1000 testers can be deleted at a time",
                                optional: true,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :group_alias,
                                 env_name: "FIREBASEAPPDISTRO_ADD_TESTERS_GROUP_ALIAS",
                                 description: "Alias of the group to add the specified testers to. The group must already exist. If not specified, testers will not be added to a group",
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :service_credentials_file,
                                description: "Path to Google service credentials file",
                                optional: true,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :firebase_cli_token,
                                 description: "Auth token generated using the Firebase CLI's login:ci command",
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :debug,
                                 description: "Print verbose debug output",
                                 optional: true,
                                 default_value: false,
                                 is_string: false)
  ]
end

.descriptionObject



44
45
46
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_add_testers_action.rb', line 44

def self.description
  "Create testers in bulk from a comma-separated list or a file"
end

.detailsObject

supports markdown.



53
54
55
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_add_testers_action.rb', line 53

def self.details
  "Create testers in bulk from a comma-separated list or a file"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


95
96
97
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_add_testers_action.rb', line 95

def self.is_supported?(platform)
  true
end

.run(params) ⇒ Object



13
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
# File 'lib/fastlane/plugin/firebase_app_distribution/actions/firebase_app_distribution_add_testers_action.rb', line 13

def self.run(params)
  auth_token = fetch_auth_token(params[:service_credentials_file], params[:firebase_cli_token])
  fad_api_client = Client::FirebaseAppDistributionApiClient.new(auth_token, params[:debug])

  if blank?(params[:emails]) && blank?(params[:file])
    UI.user_error!("Must specify `emails` or `file`.")
  end

  emails = string_to_array(get_value_from_value_or_file(params[:emails], params[:file]))

  UI.user_error!("Must pass at least one email") if blank?(emails)

  if emails.count > 1000
    UI.user_error!("A maximum of 1000 testers can be added at a time.")
  end

  UI.message("⏳ Adding #{emails.count} testers to project #{params[:project_number]}...")

  fad_api_client.add_testers(params[:project_number], emails)

  unless blank?(params[:group_alias])
    UI.message("⏳ Adding testers to group #{params[:group_alias]}...")
    fad_api_client.add_testers_to_group(params[:project_number], params[:group_alias], emails)
  end

  # The add_testers response lists all the testers from the request
  # regardless of whether or not they were created or if they already
  # exists so can't get an accurate count of the number of newly created testers
  UI.success("✅ Tester(s) successfully added.")
end