Class: Fastlane::Helper::BrowserstackHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/browserstack/helper/browserstack_helper.rb

Class Method Summary collapse

Class Method Details

.show_messageObject

class methods that you define here become available in your action as Helper::BrowserstackHelper.your_method



12
13
14
# File 'lib/fastlane/plugin/browserstack/helper/browserstack_helper.rb', line 12

def self.show_message
  UI.message("Hello from the browserstack plugin helper!")
end

.upload_file(browserstack_username, browserstack_access_key, file_path, url) ⇒ Object

Uploads file to BrowserStack Params :

browserstack_username

BrowserStack’s username.

browserstack_access_key

BrowserStack’s access key.

file_path

Path to the file to be uploaded.

url

BrowserStack’s app upload endpoint.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fastlane/plugin/browserstack/helper/browserstack_helper.rb', line 22

def self.upload_file(browserstack_username, browserstack_access_key, file_path, url)
  begin
    response = RestClient::Request.execute(
      method: :post,
      url: url,
      user: browserstack_username,
      password: browserstack_access_key,
      payload: {
        multipart: true,
        file: File.new(file_path, 'rb')
      }
    )
  rescue RestClient::ExceptionWithResponse => err
    error_response = err.response
  end

  # Return app_url if file was uploaded successfully.
  return JSON.parse(response.to_s)["app_url"] unless response.nil?

  # Give error if upload failed.
  UI.user_error!("App upload failed!!! Reason : " + JSON.parse(error_response.to_s)["error"]) unless error_response.nil?
end