Class: Fastlane::Actions::ZealotSyncDevicesAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::ZealotSyncDevicesAction
- Extended by:
- Helper::ZealotHelper
- Defined in:
- lib/fastlane/plugin/zealot/actions/zealot_sync_devices.rb
Constant Summary
Constants included from Helper::ZealotHelper
Helper::ZealotHelper::UPLOAD_APP_PARAMS_KEYS
Documentation collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .category ⇒ Object
- .description ⇒ Object
- .example_code ⇒ Object
- .is_supported?(_) ⇒ Boolean
Class Method Summary collapse
Methods included from Helper::ZealotHelper
avialable_upload_app_params, build_app_version_check_params, build_table_data, check_app_version, detect_ci_url, detect_source, gitlab?, hidden_keys, http_request, jenkins?, make_connection, print_table, show_error, sync_deivce, upload_app, upload_app_params, upload_debug_file, upload_debug_file_params
Class Method Details
.authors ⇒ Object
178 179 180 |
# File 'lib/fastlane/plugin/zealot/actions/zealot_sync_devices.rb', line 178 def self. ['icyleaf'] end |
.available_options ⇒ Object
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 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 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/fastlane/plugin/zealot/actions/zealot_sync_devices.rb', line 72 def self. [ FastlaneCore::ConfigItem.new(key: :endpoint, env_name: 'ZEALOT_ENDPOINT', description: 'The endpoint of zealot', type: String), FastlaneCore::ConfigItem.new(key: :token, env_name: 'ZEALOT_TOKEN', description: 'The token of user', sensitive: true, verify_block: proc do |value| UI.user_error!("No user token for Zealot given, pass using `token: 'token'`") if value.nil? || value.empty? end, type: String), FastlaneCore::ConfigItem.new(key: :username, env_name: 'ZEALOT_USERNAME', description: 'The apple id (username) of Apple Developer Portal', default_value_dynamic: true, optional: true, type: String), FastlaneCore::ConfigItem.new(key: :api_key_path, env_name: 'ZEALOT_API_PATH', description: 'Path to your App Store Connect API Key JSON file (https://docs.fastlane.tools/app-store-connect-api/#using-fastlane-api-key-json-file)', optional: true, conflicting_options: [:api_key], verify_block: proc do |value| UI.user_error!("Couldn't find API key JSON file at path '#{value}'") unless File.exist?(value) end), FastlaneCore::ConfigItem.new(key: :api_key, env_name: 'ZEALOT_API_KEY', description: 'Your App Store Connect API Key information (https://docs.fastlane.tools/app-store-connect-api/#using-fastlane-api-key-hash-option)', type: Hash, default_value: Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::APP_STORE_CONNECT_API_KEY], default_value_dynamic: true, optional: true, sensitive: true, conflicting_options: [:api_key_path]), FastlaneCore::ConfigItem.new(key: :team_id, env_name: 'ZEALOT_APPLE_TEAM_ID', description: 'The ID of your Developer Portal team if you\'re in multiple teams', default_value: CredentialsManager::AppfileConfig.try_fetch_value(:team_id), default_value_dynamic: true, optional: true, type: String, verify_block: proc do |value| ENV['FASTLANE_TEAM_ID'] = value.to_s end), FastlaneCore::ConfigItem.new(key: :team_name, env_name: 'ZEALOT_APPLE_TEAM_NAME', description: 'The name of your Developer Portal team if you\'re in multiple teams', default_value: CredentialsManager::AppfileConfig.try_fetch_value(:team_id), default_value_dynamic: true, optional: true, type: String, verify_block: proc do |value| ENV['FASTLANE_TEAM_NAME'] = value.to_s end), FastlaneCore::ConfigItem.new(key: :platform, env_name: 'ZEALOT_APPLE_PLATFORM', description: 'The platform to use (optional)', optional: true, default_value: 'ios', verify_block: proc do |value| UI.user_error!('The platform can only be ios or mac') unless %('ios', 'mac').include?(value) end), FastlaneCore::ConfigItem.new(key: :verify_ssl, env_name: 'ZEALOT_VERIFY_SSL', description: 'Should verify SSL of zealot service', optional: true, default_value: true, type: Boolean), FastlaneCore::ConfigItem.new(key: :timeout, env_name: 'ZEALOT_TIMEOUT', description: 'Request timeout in seconds', type: Integer, optional: true), FastlaneCore::ConfigItem.new(key: :fail_on_error, env_name: 'ZEALOT_FAIL_ON_ERROR', description: 'Should an error http request cause a failure? (true/false)', optional: true, default_value: false, type: Boolean) ] end |
.category ⇒ Object
174 175 176 |
# File 'lib/fastlane/plugin/zealot/actions/zealot_sync_devices.rb', line 174 def self.category :beta end |
.description ⇒ Object
68 69 70 |
# File 'lib/fastlane/plugin/zealot/actions/zealot_sync_devices.rb', line 68 def self.description 'Sync ios devices list to Zealot' end |
.example_code ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/fastlane/plugin/zealot/actions/zealot_sync_devices.rb', line 157 def self.example_code [ 'zealot_sync_devices( endpoint: "...", token: "...", api_key_path: "...", team_id: "..." )', 'zealot_sync_devices( endpoint: "...", token: "...", username: "...", team_id: "..." )' ] end |
.is_supported?(_) ⇒ Boolean
182 183 184 |
# File 'lib/fastlane/plugin/zealot/actions/zealot_sync_devices.rb', line 182 def self.is_supported?(_) 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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/fastlane/plugin/zealot/actions/zealot_sync_devices.rb', line 13 def self.run(params) require 'spaceship' UI.warn('Zealot v4.5.0 starts to support Apple developer features to enable automatic synchronization of test devices.') UI.warn('Link to view detail: https://zealot.ews.im/docs/user-guide/administrator/apple-team') all_platforms = Set[params[:platform]] supported_platforms = all_platforms.select { |platform| self.is_supported?(platform.to_sym) } if (api_token = Spaceship::ConnectAPI::Token.from(hash: params[:api_key], filepath: params[:api_key_path])) UI.('Creating authorization token for App Store Connect API') Spaceship::ConnectAPI.token = api_token devices = supported_platforms.flat_map do |platform| Spaceship::ConnectAPI::Device.all(filter: { platform: platform == 'ios' ? 'IOS' : 'MAC_OS'}) end else username = params[:username] UI.("Login to App Store Connect (#{username})") credentials = CredentialsManager::AccountManager.new(user: username) Spaceship.login(credentials.user, credentials.password) UI.('Login successful') Spaceship.select_team # Fetches all devices includes macOS. devices = supported_platforms.flat_map { |platform| Spaceship::Device.all(mac: platform == 'mac') } end UI.('Fetching list of currently registered devices...') print_table(build_table_data(params, devices), title: 'zealot_sync_devices') UI.("Syncing devices to #{params[:endpoint]} ...") failed_devices = [] devices.each do |device| begin sync_deivce(params, device) rescue Faraday::ConnectionFailed failed_devices << {udid: device.udid, error: 'Can not connecting to Zealot'} rescue Faraday::TimeoutError failed_devices << {udid: device.udid, error: 'Timed out to Zealot'} end end failed = failed_devices.size successed = devices.size - failed UI.success "Successful Synced devices, success: #{successed}, failed: #{failed}" UI.verbose "Failed devices: #{failed_devices}" end |