fastlane-plugin-browserstack 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55584378299e9edec8b0e2982d7c9f66941554625689d41af193718fa87d5440
|
4
|
+
data.tar.gz: 115f1239640f5283712744662793952532c10300542038f4b90e84250515ccaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbd5d95f8b12bacf1af867d90e24a72c859346ad38139530c60f741967b76034faa1fd9624fdcef0e636d806ff5478c94a7dc7479ac174d0154052d4028f6878
|
7
|
+
data.tar.gz: f3bc87d0b59893d2dcae92af2cf934986033fc01c2d561ad80c83cc2b08e4d406763791a35aa7c26098ad7feb4f28c34fb215bda0c57d2119f2e336ab7a6f4a4
|
data/README.md
CHANGED
@@ -18,6 +18,8 @@ Uploads IPA and APK files to BrowserStack for automation and manual testing.
|
|
18
18
|
|
19
19
|
Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by including that in your project's Fastfile, running `fastlane install_plugins` and `bundle exec fastlane test`.
|
20
20
|
|
21
|
+
Please refer this [sample android project](https://github.com/browserstack/browserstack-android-sample-app), which demonstrates the use of this plugin.
|
22
|
+
|
21
23
|
## Run tests for this plugin
|
22
24
|
|
23
25
|
To run both the tests, and code style validation, run
|
@@ -14,13 +14,14 @@ module Fastlane
|
|
14
14
|
def self.run(params)
|
15
15
|
browserstack_username = params[:browserstack_username] # Required
|
16
16
|
browserstack_access_key = params[:browserstack_access_key] # Required
|
17
|
+
browserstack_custom_id = params[:browserstack_custom_id]
|
17
18
|
file_path = params[:file_path].to_s # Required
|
18
19
|
|
19
20
|
validate_file_path(file_path)
|
20
21
|
|
21
22
|
UI.message("Uploading app to BrowserStack AppAutomate...")
|
22
23
|
|
23
|
-
browserstack_app_id = Helper::BrowserstackHelper.upload_file(browserstack_username, browserstack_access_key, file_path, UPLOAD_API_ENDPOINT)
|
24
|
+
browserstack_app_id = Helper::BrowserstackHelper.upload_file(browserstack_username, browserstack_access_key, file_path, UPLOAD_API_ENDPOINT, browserstack_custom_id)
|
24
25
|
|
25
26
|
# Set 'BROWSERSTACK_APP_ID' environment variable, if app upload was successful.
|
26
27
|
ENV['BROWSERSTACK_APP_ID'] = browserstack_app_id
|
@@ -89,6 +90,10 @@ module Fastlane
|
|
89
90
|
verify_block: proc do |value|
|
90
91
|
UI.user_error!("No browserstack_access_key given.") if value.to_s.empty?
|
91
92
|
end),
|
93
|
+
FastlaneCore::ConfigItem.new(key: :browserstack_custom_id,
|
94
|
+
description: "BrowserStack's custom id",
|
95
|
+
optional: true,
|
96
|
+
is_string: true),
|
92
97
|
FastlaneCore::ConfigItem.new(key: :file_path,
|
93
98
|
description: "Path to the app file",
|
94
99
|
optional: true,
|
@@ -17,29 +17,50 @@ module Fastlane
|
|
17
17
|
# Params :
|
18
18
|
# +browserstack_username+:: BrowserStack's username.
|
19
19
|
# +browserstack_access_key+:: BrowserStack's access key.
|
20
|
+
# +browserstack_custom_id+:: BrowserStacks's custom id.
|
20
21
|
# +file_path+:: Path to the file to be uploaded.
|
21
22
|
# +url+:: BrowserStack's app upload endpoint.
|
22
|
-
def self.upload_file(browserstack_username, browserstack_access_key, file_path, url)
|
23
|
+
def self.upload_file(browserstack_username, browserstack_access_key, file_path, url, browserstack_custom_id = nil)
|
24
|
+
payload = {
|
25
|
+
multipart: true,
|
26
|
+
file: File.new(file_path, 'rb')
|
27
|
+
}
|
28
|
+
|
29
|
+
unless browserstack_custom_id.nil?
|
30
|
+
payload[:data] = '{ "custom_id": "' + browserstack_custom_id + '" }'
|
31
|
+
end
|
32
|
+
|
33
|
+
headers = {
|
34
|
+
"User-Agent" => "browserstack_fastlane_plugin"
|
35
|
+
}
|
23
36
|
begin
|
24
37
|
response = RestClient::Request.execute(
|
25
38
|
method: :post,
|
26
39
|
url: url,
|
27
40
|
user: browserstack_username,
|
28
41
|
password: browserstack_access_key,
|
29
|
-
payload:
|
30
|
-
|
31
|
-
file: File.new(file_path, 'rb')
|
32
|
-
}
|
42
|
+
payload: payload,
|
43
|
+
headers: headers
|
33
44
|
)
|
34
|
-
rescue RestClient::ExceptionWithResponse => err
|
35
|
-
error_response = err.response
|
36
|
-
end
|
37
45
|
|
38
|
-
|
39
|
-
return JSON.parse(response.to_s)["app_url"] unless response.nil?
|
46
|
+
response_json = JSON.parse(response.to_s)
|
40
47
|
|
41
|
-
|
42
|
-
|
48
|
+
if !response_json["custom_id"].nil?
|
49
|
+
return response_json["custom_id"]
|
50
|
+
else
|
51
|
+
return response_json["app_url"]
|
52
|
+
end
|
53
|
+
rescue RestClient::ExceptionWithResponse => err
|
54
|
+
begin
|
55
|
+
error_response = JSON.parse(err.response.to_s)["error"]
|
56
|
+
rescue
|
57
|
+
error_response = "Internal server error"
|
58
|
+
end
|
59
|
+
# Give error if upload failed.
|
60
|
+
UI.user_error!("App upload failed!!! Reason : #{error_response}")
|
61
|
+
rescue StandardError => error
|
62
|
+
UI.user_error!("App upload failed!!! Reason : #{error.message}")
|
63
|
+
end
|
43
64
|
end
|
44
65
|
end
|
45
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-browserstack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BrowserStack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|