Class: Fastlane::Actions::SaucelabsUploadAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::SaucelabsUploadAction
- Defined in:
- lib/fastlane/plugin/saucelabs/actions/saucelabs_upload_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .example_code ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .output ⇒ Object
- .return_value ⇒ Object
-
.run(params) ⇒ Object
noinspection RubyResolve.
- .upload(payload:, app_name:, app_description:, user_name:, api_key:, region:) ⇒ Object
Class Method Details
.authors ⇒ Object
70 71 72 |
# File 'lib/fastlane/plugin/saucelabs/actions/saucelabs_upload_action.rb', line 70 def self. ["@CloudKats https://github.com/cloudkats"] end |
.available_options ⇒ Object
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 |
# File 'lib/fastlane/plugin/saucelabs/actions/saucelabs_upload_action.rb', line 83 def self. [ FastlaneCore::ConfigItem.new(key: :file, env_name: "", description: "zip file for the upload", optional: false, type: String, verify_block: proc do |value| if value UI.user_error!("Could not find file to upload \"#{file}\" ") unless File.exist?(value) || Helper.test? accepted_formats = %w(.api .ipa) file_ext = Helper::SaucelabsHelper.file_extname(accepted_formats, value) # UI.user_error!("Extension not supported for \"#{file}\" ") unless accepted_formats.include? file_ext end end), FastlaneCore::ConfigItem.new(key: :app_name, env_name: "SAUCE_APP_NAME", description: "App name as found in the App's URL in Sauce Labs", default_value: Actions.lane_context[SharedValues::SAUCE_ITEM_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: :app_description, description: "App description as it found in \"item.description\" Sauce Labs", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :user_name, env_name: "SAUCE_USERNAME", description: "The Sauce Labs API uses basic auth username to authenticate requests", default_value: Actions.lane_context[SharedValues::SAUCE_USERNAME], optional: false, type: String, verify_block: proc do |value| UI.user_error!("No API username given, pass using `username: 'sauce user name'`") unless value && !value.empty? end), FastlaneCore::ConfigItem.new(key: :api_key, env_name: "SAUCE_ACCESS_KEY", description: "The Sauce Labs API uses API keys to authenticate requests", default_value: Actions.lane_context[SharedValues::SAUCE_ACCESS_KEY], optional: false, type: String, verify_block: proc do |value| UI.user_error!("No API key given, pass using `apikey: 'sauce access key'`") unless value && !value.empty? end), FastlaneCore::ConfigItem.new(key: :region, env_name: "SAUCE_REGION", description: "Api endpoint region e.g. 'us', 'us-west-1', 'eu' or 'eu-central-1' ", default_value: Actions.lane_context[SharedValues::SAUCE_REGION], optional: false, type: String, verify_block: proc do |value| accepted_formats = %w[us us-west-1 eu-central-1 eu] UI.user_error!("Only \"us\", \"eu\", \"us-west-1\" and \"eu-central-1\", types are allowed, you provided \"#{value}\"") unless accepted_formats.include? value || Helper.test? end) ] end |
.description ⇒ Object
66 67 68 |
# File 'lib/fastlane/plugin/saucelabs/actions/saucelabs_upload_action.rb', line 66 def self.description "Sauce labs android & ios Fastlane plugin" end |
.details ⇒ Object
78 79 80 81 |
# File 'lib/fastlane/plugin/saucelabs/actions/saucelabs_upload_action.rb', line 78 def self.details # Optional: "Upload ios&android artifacts to Sauce Labs https://docs.saucelabs.com/" end |
.example_code ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/fastlane/plugin/saucelabs/actions/saucelabs_upload_action.rb', line 154 def self.example_code [ 'saucelabs_upload( user_name: "user name", api_key: "api key", app_name: "Android.artifact.apk", file: "app/build/outputs/apk/debug/app-debug.apk", region: "eu" )', 'saucelabs_upload( user_name: "user name", api_key: "api key", app_name: "iOS.artifact.ipa", file: "app.ipa", description region: "us-west-1" )' ] end |
.is_supported?(platform) ⇒ Boolean
174 175 176 177 178 179 180 |
# File 'lib/fastlane/plugin/saucelabs/actions/saucelabs_upload_action.rb', line 174 def self.is_supported?(platform) # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example) # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform # # [:ios, :mac, :android].include?(platform) true end |
.output ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/fastlane/plugin/saucelabs/actions/saucelabs_upload_action.rb', line 142 def self.output [ ['SAUCE_USERNAME', 'Contains API user name'], ['SAUCE_REGION', 'Contains API region'], ['SAUCE_ITEM_NAME', 'Contains item name'], ['SAUCE_ITEM_SIZE', 'Contains item size'], ['SAUCE_ITEM_ID', 'Contains item id in uuid format'], ['SAUCE_ITEM_KIND', 'Contains item kind e.g., android or ios'], ['SAUCE_ITEM_REGION', 'Contains region where item is uploaded'] ] end |
.return_value ⇒ Object
74 75 76 |
# File 'lib/fastlane/plugin/saucelabs/actions/saucelabs_upload_action.rb', line 74 def self.return_value # If your method provides a return value, you can describe here what it does end |
.run(params) ⇒ Object
noinspection RubyResolve
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fastlane/plugin/saucelabs/actions/saucelabs_upload_action.rb', line 20 def self.run(params) UI.("The saucelabs plugin is working!") file = params[:file] region = params[:region] username = params[:user_name] apikey = params[:api_key] app_name = params[:app_name] app_description = params[:app_description] if file.to_s.length == 0 UI.user_error!("Couldn't find build file at path #{file}` ❌") end upload(payload: file, app_name: app_name, app_description: app_description, user_name: username, api_key: apikey, region: region) end |
.upload(payload:, app_name:, app_description:, user_name:, api_key:, region:) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/fastlane/plugin/saucelabs/actions/saucelabs_upload_action.rb', line 41 def self.upload(payload:, app_name:, app_description:, user_name:, api_key:, region:) UI.("Starting \"#{app_name}\" upload to Sauce Labs...") begin result = Helper::SaucelabsHelper.upload( payload: payload, app_name: app_name, app_description: app_description, user_name: user_name, api_key: api_key, region: region) if result and result.is_a?(Hash) Actions.lane_context[SharedValues::SAUCE_ITEM_NAME] = result[:name] if result.has_key?(:name) Actions.lane_context[SharedValues::SAUCE_ITEM_KIND] = result[:kind] if result.has_key?(:kind) Actions.lane_context[SharedValues::SAUCE_ITEM_ID] = result[:id] if result.has_key?(:id) Actions.lane_context[SharedValues::SAUCE_ITEM_SIZE] = result[:size] if result.has_key?(:size) Actions.lane_context[SharedValues::SAUCE_ITEM_REGION] = result[:region] if result.has_key?(:region) end UI.("Upload \"#{app_name}\" ✅") rescue => exception UI.user_error!("Failed to upload ❌. #{exception.to_s}") end end |