Class: Fastlane::Actions::XcodeServerGetAssetsAction
- Inherits:
-
Fastlane::Action
- Object
- Fastlane::Action
- Fastlane::Actions::XcodeServerGetAssetsAction
- Defined in:
- fastlane/lib/fastlane/actions/xcode_server_get_assets.rb
Defined Under Namespace
Classes: XcodeServer
Constant Summary
Constants inherited from Fastlane::Action
Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES
Documentation collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .category ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .example_code ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .output ⇒ Object
- .return_type ⇒ Object
Class Method Summary collapse
Methods inherited from Fastlane::Action
action_name, author, deprecated_notes, lane_context, method_missing, other_action, return_value, sample_return_value, shell_out_should_use_bundle_exec?, step_text
Class Method Details
.authors ⇒ Object
290 291 292 |
# File 'fastlane/lib/fastlane/actions/xcode_server_get_assets.rb', line 290 def self. ["czechboy0"] end |
.available_options ⇒ Object
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
# File 'fastlane/lib/fastlane/actions/xcode_server_get_assets.rb', line 233 def self. [ FastlaneCore::ConfigItem.new(key: :host, env_name: "FL_XCODE_SERVER_GET_ASSETS_HOST", description: "IP Address/Hostname of Xcode Server", optional: false), FastlaneCore::ConfigItem.new(key: :bot_name, env_name: "FL_XCODE_SERVER_GET_ASSETS_BOT_NAME", description: "Name of the Bot to pull assets from", optional: false), FastlaneCore::ConfigItem.new(key: :integration_number, env_name: "FL_XCODE_SERVER_GET_ASSETS_INTEGRATION_NUMBER", description: "Optionally you can override which integration's assets should be downloaded. If not provided, the latest integration is used", type: Integer, optional: true), FastlaneCore::ConfigItem.new(key: :username, env_name: "FL_XCODE_SERVER_GET_ASSETS_USERNAME", description: "Username for your Xcode Server", optional: true, default_value: ""), FastlaneCore::ConfigItem.new(key: :password, env_name: "FL_XCODE_SERVER_GET_ASSETS_PASSWORD", description: "Password for your Xcode Server", sensitive: true, optional: true, default_value: ""), FastlaneCore::ConfigItem.new(key: :target_folder, env_name: "FL_XCODE_SERVER_GET_ASSETS_TARGET_FOLDER", description: "Relative path to a folder into which to download assets", optional: true, default_value: './xcs_assets'), FastlaneCore::ConfigItem.new(key: :keep_all_assets, env_name: "FL_XCODE_SERVER_GET_ASSETS_KEEP_ALL_ASSETS", description: "Whether to keep all assets or let the script delete everything except for the .xcarchive", optional: true, type: Boolean, default_value: false), FastlaneCore::ConfigItem.new(key: :trust_self_signed_certs, env_name: "FL_XCODE_SERVER_GET_ASSETS_TRUST_SELF_SIGNED_CERTS", description: "Whether to trust self-signed certs on your Xcode Server", optional: true, type: Boolean, default_value: true) ] end |
.category ⇒ Object
307 308 309 |
# File 'fastlane/lib/fastlane/actions/xcode_server_get_assets.rb', line 307 def self.category :testing end |
.description ⇒ Object
221 222 223 |
# File 'fastlane/lib/fastlane/actions/xcode_server_get_assets.rb', line 221 def self.description "Downloads Xcode Bot assets like the `.xcarchive` and logs" end |
.details ⇒ Object
225 226 227 228 229 230 231 |
# File 'fastlane/lib/fastlane/actions/xcode_server_get_assets.rb', line 225 def self.details [ "This action downloads assets from your Xcode Server Bot (works with Xcode Server using Xcode 6 and 7. By default, this action downloads all assets, unzips them and deletes everything except for the `.xcarchive`.", "If you'd like to keep all downloaded assets, pass `keep_all_assets: true`.", "This action returns the path to the downloaded assets folder and puts into shared values the paths to the asset folder and to the `.xcarchive` inside it." ].join("\n") end |
.example_code ⇒ Object
298 299 300 301 302 303 304 305 |
# File 'fastlane/lib/fastlane/actions/xcode_server_get_assets.rb', line 298 def self.example_code [ 'xcode_server_get_assets( host: "10.99.0.59", # Specify Xcode Server\'s Host or IP Address bot_name: "release-1.3.4" # Specify the particular Bot )' ] end |
.is_supported?(platform) ⇒ Boolean
294 295 296 |
# File 'fastlane/lib/fastlane/actions/xcode_server_get_assets.rb', line 294 def self.is_supported?(platform) [:ios, :mac].include?(platform) end |
.output ⇒ Object
279 280 281 282 283 284 |
# File 'fastlane/lib/fastlane/actions/xcode_server_get_assets.rb', line 279 def self.output [ ['XCODE_SERVER_GET_ASSETS_PATH', 'Absolute path to the downloaded assets folder'], ['XCODE_SERVER_GET_ASSETS_ARCHIVE_PATH', 'Absolute path to the downloaded xcarchive file'] ] end |
.return_type ⇒ Object
286 287 288 |
# File 'fastlane/lib/fastlane/actions/xcode_server_get_assets.rb', line 286 def self.return_type :array_of_strings 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 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 104 105 106 |
# File 'fastlane/lib/fastlane/actions/xcode_server_get_assets.rb', line 13 def self.run(params) host = params[:host] bot_name = params[:bot_name] integration_number_override = params[:integration_number] target_folder = params[:target_folder] keep_all_assets = params[:keep_all_assets] username = params[:username] password = params[:password] trust_self_signed_certs = params[:trust_self_signed_certs] # setup (not)trusting self signed certificates. # it's normal to have a self signed certificate on your Xcode Server Excon.defaults[:ssl_verify_peer] = !trust_self_signed_certs # for self-signed certificates # create Xcode Server config xcs = XcodeServer.new(host, username, password) bots = xcs.fetch_all_bots UI.important("Fetched #{bots.count} Bots from Xcode Server at #{host}.") # pull out names bot_names = bots.map { |bot| bot['name'] } # match the bot name with a found bot, otherwise fail found_bots = bots.select { |bot| bot['name'] == bot_name } UI.user_error!("Failed to find a Bot with name #{bot_name} on server #{host}, only available Bots: #{bot_names}") if found_bots.count == 0 bot = found_bots[0] UI.success("Found Bot with name #{bot_name} with id #{bot['_id']}.") # we have our bot, get finished integrations, sorted from newest to oldest integrations = xcs.fetch_integrations(bot['_id']).select { |i| i['currentStep'] == 'completed' } UI.user_error!("Failed to find any completed integration for Bot \"#{bot_name}\"") if (integrations || []).count == 0 # if no integration number is specified, pick the newest one (this is sorted from newest to oldest) if integration_number_override integration = integrations.find { |i| i['number'] == integration_number_override } UI.user_error!("Specified integration number #{integration_number_override} does not exist.") unless integration else integration = integrations.first end # consider: only taking the last successful one? or allow failing tests? warnings? UI.important("Using integration #{integration['number']}.") # fetch assets for this integration assets_path = xcs.fetch_assets(integration['_id'], target_folder, self) UI.user_error!("Failed to fetch assets for integration #{integration['number']}.") unless assets_path asset_entries = Dir.entries(assets_path).map { |i| File.join(assets_path, i) } UI.success("Successfully downloaded #{asset_entries.count} assets to file #{assets_path}!") # now find the archive and unzip it zipped_archive_path = asset_entries.find { |i| i.end_with?('xcarchive.zip') } if zipped_archive_path UI.important("Found an archive in the assets folder...") archive_file_path = File.basename(zipped_archive_path, File.extname(zipped_archive_path)) archive_dir_path = File.dirname(zipped_archive_path) archive_path = File.join(archive_dir_path, archive_file_path) if File.exist?(archive_path) # we already have the archive, skip UI.important("Archive #{archive_path} already exists, not unzipping again...") else # unzip the archive sh("unzip -q \"#{zipped_archive_path}\" -d \"#{archive_dir_path}\"") end # reload asset entries to also contain the xcarchive file asset_entries = Dir.entries(assets_path).map { |i| File.join(assets_path, i) } # optionally delete everything except for the archive unless keep_all_assets files_to_delete = asset_entries.select do |i| File.extname(i) != '.xcarchive' && ![".", ".."].include?(File.basename(i)) end files_to_delete.each do |i| FileUtils.rm_rf(i) end end Actions.lane_context[SharedValues::XCODE_SERVER_GET_ASSETS_ARCHIVE_PATH] = archive_path end Actions.lane_context[SharedValues::XCODE_SERVER_GET_ASSETS_PATH] = assets_path return assets_path end |