Class: Fastlane::Actions::UploadToBrowserstackAppLiveAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::UploadToBrowserstackAppLiveAction
- Defined in:
- lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_live_action.rb
Constant Summary collapse
- SUPPORTED_FILE_EXTENSIONS =
["apk", "ipa", "aab"]
- UPLOAD_API_ENDPOINT =
"https://api-cloud.browserstack.com/app-live/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.
Class Method Details
.authors ⇒ Object
51 52 53 |
# File 'lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_live_action.rb', line 51 def self. ["Hitesh Raghuvanshi"] end |
.available_options ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_live_action.rb', line 76 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: :file_path, description: "Path to the app file", optional: true, is_string: true, default_value: default_file_path) ] end |
.default_file_path ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_live_action.rb', line 65 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 if it was generated by gradle. return Actions.lane_context[Actions::SharedValues::GRADLE_APK_OUTPUT_PATH] end end |
.description ⇒ Object
47 48 49 |
# File 'lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_live_action.rb', line 47 def self.description "Uploads IPA and APK files to BrowserStack AppLive for running manual tests." end |
.details ⇒ Object
55 56 57 |
# File 'lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_live_action.rb', line 55 def self.details "Uploads IPA and APK files to BrowserStack AppLive for running manual tests." end |
.example_code ⇒ Object
104 105 106 107 108 109 110 111 112 113 |
# File 'lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_live_action.rb', line 104 def self.example_code [ 'upload_to_browserstack_app_live', 'upload_to_browserstack_app_live( 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
100 101 102 |
# File 'lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_live_action.rb', line 100 def self.is_supported?(platform) [:ios, :android].include?(platform) end |
.output ⇒ Object
59 60 61 62 63 |
# File 'lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_live_action.rb', line 59 def self.output [ ['BROWSERSTACK_LIVE_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 |
# File 'lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_live_action.rb', line 14 def self.run(params) browserstack_username = params[:browserstack_username] # Required browserstack_access_key = params[:browserstack_access_key] # Required file_path = params[:file_path].to_s # Required validate_file_path(file_path) UI.("Uploading app to BrowserStack AppLive...") browserstack_app_id = Helper::BrowserstackHelper.upload_file(browserstack_username, browserstack_access_key, file_path, UPLOAD_API_ENDPOINT) # Set 'BROWSERSTACK_APP_ID' environment variable, if app upload was successful. ENV['BROWSERSTACK_LIVE_APP_ID'] = browserstack_app_id UI.success("Successfully uploaded app " + file_path + " to BrowserStack AppLive with app_url : " + browserstack_app_id) UI.success("Setting Environment variable BROWSERSTACK_LIVE_APP_ID = " + browserstack_app_id) # Setting app id in SharedValues, which can be used by other fastlane actions. Actions.lane_context[SharedValues::BROWSERSTACK_LIVE_APP_ID] = browserstack_app_id end |
.validate_file_path(file_path) ⇒ Object
Validate file_path.
37 38 39 40 41 42 43 44 45 |
# File 'lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_live_action.rb', line 37 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 |