Class: Fastlane::Actions::UploadToBrowserstackAppAutomateAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::UploadToBrowserstackAppAutomateAction
- Defined in:
- lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_automate_action.rb
Constant Summary collapse
- SUPPORTED_FILE_EXTENSIONS =
["apk", "ipa", "aab"]
- UPLOAD_API_ENDPOINT =
"https://api-cloud.browserstack.com/app-automate/upload"
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .default_file_path ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .example_code ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .output ⇒ Object
- .run(params) ⇒ Object
-
.validate_file_path(file_path) ⇒ Object
Validate file_path.
-
.validate_ios_keychain_support(ios_keychain_support) ⇒ Object
Validate ios_keychain_support.
Class Method Details
.authors ⇒ Object
67 68 69 |
# File 'lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_automate_action.rb', line 67 def self. ["Hitesh Raghuvanshi"] end |
.available_options ⇒ Object
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 |
# File 'lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_automate_action.rb', line 99 def self. [ FastlaneCore::ConfigItem.new(key: :browserstack_username, description: "BrowserStack's username", optional: false, is_string: true, verify_block: proc do |value| UI.user_error!("No browserstack_username given.") if value.to_s.empty? end), FastlaneCore::ConfigItem.new(key: :browserstack_access_key, description: "BrowserStack's access key", optional: false, is_string: true, verify_block: proc do |value| UI.user_error!("No browserstack_access_key given.") if value.to_s.empty? end), FastlaneCore::ConfigItem.new(key: :custom_id, description: "Custom id", optional: true, is_string: true), FastlaneCore::ConfigItem.new(key: :file_path, description: "Path to the app file", optional: true, is_string: true, default_value: default_file_path), FastlaneCore::ConfigItem.new(key: :ios_keychain_support, description: "Enable/disable support for iOS keychain", optional: true, is_string: true) ] end |
.default_file_path ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_automate_action.rb', line 81 def self.default_file_path platform = Actions.lane_context[Actions::SharedValues::PLATFORM_NAME] if platform == :ios # Shared value for ipa path if it was generated by gym https://docs.fastlane.tools/actions/gym/. return Actions.lane_context[Actions::SharedValues::IPA_OUTPUT_PATH] else # Shared value for apk/aab if it was generated by gradle. apk_path = Actions.lane_context[Actions::SharedValues::GRADLE_APK_OUTPUT_PATH] aab_path = Actions.lane_context[Actions::SharedValues::GRADLE_AAB_OUTPUT_PATH] if !apk_path.nil? return apk_path else return aab_path end end end |
.description ⇒ Object
63 64 65 |
# File 'lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_automate_action.rb', line 63 def self.description "Uploads IPA and APK files to BrowserStack AppAutomate for running automated tests." end |
.details ⇒ Object
71 72 73 |
# File 'lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_automate_action.rb', line 71 def self.details "Uploads IPA and APK files to BrowserStack AppAutomate for running automated tests." end |
.example_code ⇒ Object
135 136 137 138 139 140 141 142 143 144 |
# File 'lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_automate_action.rb', line 135 def self.example_code [ 'upload_to_browserstack_app_automate', 'upload_to_browserstack_app_automate( browserstack_username: ENV["BROWSERSTACK_USERNAME"], browserstack_access_key: ENV["BROWSERSTACK_ACCESS_KEY"], file_path: "path_to_apk_or_ipa_file" )' ] end |
.is_supported?(platform) ⇒ Boolean
131 132 133 |
# File 'lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_automate_action.rb', line 131 def self.is_supported?(platform) [:ios, :android].include?(platform) end |
.output ⇒ Object
75 76 77 78 79 |
# File 'lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_automate_action.rb', line 75 def self.output [ ['BROWSERSTACK_APP_ID', 'App id of uploaded app.'] ] end |
.run(params) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_automate_action.rb', line 14 def self.run(params) browserstack_username = params[:browserstack_username] # Required browserstack_access_key = params[:browserstack_access_key] # Required custom_id = params[:custom_id] file_path = params[:file_path].to_s # Required ios_keychain_support = params[:ios_keychain_support] validate_file_path(file_path) validate_ios_keychain_support(ios_keychain_support) unless ios_keychain_support.nil? UI.("Uploading app to BrowserStack AppAutomate...") browserstack_app_id = Helper::BrowserstackHelper.upload_file(browserstack_username, browserstack_access_key, file_path, UPLOAD_API_ENDPOINT, custom_id, ios_keychain_support) # Set 'BROWSERSTACK_APP_ID' environment variable, if app upload was successful. ENV['BROWSERSTACK_APP_ID'] = browserstack_app_id UI.success("Successfully uploaded app " + file_path + " to BrowserStack AppAutomate with app_url : " + browserstack_app_id) UI.success("Setting Environment variable BROWSERSTACK_APP_ID = " + browserstack_app_id) # Setting app id in SharedValues, which can be used by other fastlane actions. Actions.lane_context[SharedValues::BROWSERSTACK_APP_ID] = browserstack_app_id end |
.validate_file_path(file_path) ⇒ Object
Validate file_path.
40 41 42 43 44 45 46 47 48 |
# File 'lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_automate_action.rb', line 40 def self.validate_file_path(file_path) UI.user_error!("No file found at '#{file_path}'.") unless File.exist?(file_path) # Validate file extension. file_path_parts = file_path.split(".") unless file_path_parts.length > 1 && SUPPORTED_FILE_EXTENSIONS.include?(file_path_parts.last) UI.user_error!("file_path is invalid, only files with extensions " + SUPPORTED_FILE_EXTENSIONS.to_s + " are allowed to be uploaded.") end end |
.validate_ios_keychain_support(ios_keychain_support) ⇒ Object
Validate ios_keychain_support
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_automate_action.rb', line 51 def self.validate_ios_keychain_support(ios_keychain_support) platform = Actions.lane_context[Actions::SharedValues::PLATFORM_NAME] if !platform.nil? && platform != :ios # Check if platform is specified and not ios # If so, then raise error. UI.user_error!("ios_keychain_support param can only be used with platform ios") end unless ['true', 'false'].include?(ios_keychain_support.to_s) UI.user_error!("ios_keychain_support should be either 'true' or 'false'.") end end |