Class: Fastlane::Actions::AppcenterFetchDevicesAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::AppcenterFetchDevicesAction
- Defined in:
- lib/fastlane/plugin/appcenter/actions/appcenter_fetch_devices_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .return_value ⇒ Object
- .run(params) ⇒ Object
- .write_devices(devices:, devices_file:) ⇒ Object
Class Method Details
.authors ⇒ Object
76 77 78 |
# File 'lib/fastlane/plugin/appcenter/actions/appcenter_fetch_devices_action.rb', line 76 def self. ["benkane"] end |
.available_options ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/fastlane/plugin/appcenter/actions/appcenter_fetch_devices_action.rb', line 90 def self. [ FastlaneCore::ConfigItem.new(key: :api_token, env_name: "APPCENTER_API_TOKEN", sensitive: true, description: "API Token for App Center", optional: false, type: String, verify_block: proc do |value| UI.user_error!("No API token for App Center given, pass using `api_token: 'token'`") unless value && !value.empty? end), FastlaneCore::ConfigItem.new(key: :owner_name, env_name: "APPCENTER_OWNER_NAME", description: "Owner name", optional: false, type: String, verify_block: proc do |value| UI.user_error!("No Owner name for App Center given, pass using `owner_name: 'name'`") unless value && !value.empty? end), FastlaneCore::ConfigItem.new(key: :app_name, env_name: "APPCENTER_APP_NAME", description: "App name", optional: false, type: String, verify_block: proc do |value| UI.user_error!("No App name given, pass using `app_name: 'app name'`") unless value && !value.empty? end), FastlaneCore::ConfigItem.new(key: :devices_file, env_name: "FL_REGISTER_DEVICES_FILE", description: "File to save devices to", type: String, default_value: "devices.txt", verify_block: proc do |value| UI.important("Important: Devices file is #{value}. If you plan to upload this file to Apple Developer Center, the file must have the .txt extension") unless value && value.end_with?('.txt') end), FastlaneCore::ConfigItem.new(key: :destinations, env_name: "APPCENTER_DISTRIBUTE_DESTINATIONS", description: "Comma separated list of distribution group names. Default is 'Collaborators', use '*' for all distribution groups", default_value: "Collaborators", type: String) ] end |
.description ⇒ Object
72 73 74 |
# File 'lib/fastlane/plugin/appcenter/actions/appcenter_fetch_devices_action.rb', line 72 def self.description "Fetches a list of devices from App Center to distribute an iOS app to" end |
.details ⇒ Object
84 85 86 87 88 |
# File 'lib/fastlane/plugin/appcenter/actions/appcenter_fetch_devices_action.rb', line 84 def self.details "List is a tab-delimited CSV file containing every device from specified distribution groups for an app in App Center. " + "Especially useful when combined with register_devices and match to automatically register and provision devices with Apple. " + "By default, only the Collaborators group will be included, use `destination: '*'` to match all groups." end |
.is_supported?(platform) ⇒ Boolean
133 134 135 |
# File 'lib/fastlane/plugin/appcenter/actions/appcenter_fetch_devices_action.rb', line 133 def self.is_supported?(platform) [:ios].include?(platform) end |
.return_value ⇒ Object
80 81 82 |
# File 'lib/fastlane/plugin/appcenter/actions/appcenter_fetch_devices_action.rb', line 80 def self.return_value "CSV file formatted for multi-device registration with Apple" end |
.run(params) ⇒ Object
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 |
# File 'lib/fastlane/plugin/appcenter/actions/appcenter_fetch_devices_action.rb', line 15 def self.run(params) api_token = params[:api_token] owner_name = params[:owner_name] app_name = params[:app_name] destinations = params[:destinations] Actions.lane_context[SharedValues::APPCENTER_API_TOKEN] = api_token Actions.lane_context[SharedValues::APPCENTER_OWNER_NAME] = owner_name Actions.lane_context[SharedValues::APPCENTER_APP_NAME] = app_name group_names = [] if destinations == '*' UI.("Looking up all distribution groups for #{owner_name}/#{app_name}") distribution_groups = Helper::AppcenterHelper.fetch_distribution_groups( api_token: api_token, owner_name: owner_name, app_name: app_name ) UI.("Failed to list distribution groups for #{owner_name}/#{app_name}") unless distribution_groups distribution_groups.each do |group| group_names << group['name'] end else group_names += destinations.split(',').map(&:strip) end Actions.lane_context[SharedValues::APPCENTER_DISTRIBUTE_DESTINATIONS] = group_names.join(',') devices = [] group_names.each do |group_name| group_devices = Helper::AppcenterHelper.fetch_devices( api_token: api_token, owner_name: owner_name, app_name: app_name, distribution_group: group_name ) UI.("Failed to get devices for group '#{group_name}'") unless group_devices devices << group_devices end self.write_devices(devices: devices, devices_file: params[:devices_file]) end |
.write_devices(devices:, devices_file:) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/fastlane/plugin/appcenter/actions/appcenter_fetch_devices_action.rb', line 58 def self.write_devices(devices:, devices_file:) CSV.open(devices_file, 'w', write_headers: true, headers: ['Device ID', 'Device Name'], col_sep: "\t") do |csv| devices.each do |device| CSV.parse(device, col_sep: "\t", headers: true) do |row| csv << row end end end end |