Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ For uploading your app to AppLive use the following action in the fastfile
upload_to_browserstack_app_live(
browserstack_username: ENV["BROWSERSTACK_USERNAME"],
browserstack_access_key: ENV["BROWSERSTACK_ACCESS_KEY"],
file_path: "<path_to_your_apk_ipa_or_aab_file>"
file_path: "<path_to_your_apk_ipa_or_aab_file>",
custom_id: "<custom_id_name>"
)
```
```
Note: custom_id is optional. You can upload multiple builds under the same custom_id.
```
Check out the example [Fastfile](https://github.com/browserstack/browserstack-fastlane-plugin/blob/master/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`. Please refer to this [sample android project](https://github.com/browserstack/browserstack-android-sample-app), which demonstrates the use of this plugin.

Once the app upload is successful, the app id of the app will be stored in an environment variable, "BROWSERSTACK_APP_ID" and it can be accessed in your tests in the following way :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ 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
custom_id = params[:custom_id]

validate_file_path(file_path)

UI.message("Uploading app to BrowserStack AppLive...")

browserstack_app_id = Helper::BrowserstackHelper.upload_file(browserstack_username, browserstack_access_key, file_path, UPLOAD_API_ENDPOINT)
browserstack_app_id = Helper::BrowserstackHelper.upload_file(browserstack_username, browserstack_access_key, file_path, UPLOAD_API_ENDPOINT, custom_id)

# Set 'BROWSERSTACK_APP_ID' environment variable, if app upload was successful.
ENV['BROWSERSTACK_LIVE_APP_ID'] = browserstack_app_id
Expand Down Expand Up @@ -100,7 +101,11 @@ def self.available_options
description: "Path to the app file",
optional: true,
is_string: true,
default_value: default_file_path)
default_value: default_file_path),
FastlaneCore::ConfigItem.new(key: :custom_id,
description: "Custom id",
optional: true,
is_string: true)
]
end

Expand Down
16 changes: 16 additions & 0 deletions spec/upload_to_browserstack_app_live_action_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
describe Fastlane::Actions::UploadToBrowserstackAppLiveAction do
describe 'Upload to BrowserStack AppLive' do
let(:custom_id) { "customId" }

before(:each) do
Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::GRADLE_APK_OUTPUT_PATH] = nil
Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::GRADLE_AAB_OUTPUT_PATH] = nil
Expand Down Expand Up @@ -129,5 +131,19 @@
end").runner.execute(:test)
expect(ENV['BROWSERSTACK_LIVE_APP_ID']).to eq("bs://app_url")
end

it "should work with custom id" do
ENV['BROWSERSTACK_LIVE_APP_ID'] = nil
expect(RestClient::Request).to receive(:execute).and_return({ "app_url" => "bs://app_url", "custom_id" => custom_id, "shareable_id" => "username/#{custom_id}" }.to_json)
Fastlane::FastFile.new.parse("lane :test do
upload_to_browserstack_app_live({
browserstack_username: 'username',
browserstack_access_key: 'access_key',
custom_id: '#{custom_id}',
file_path: File.join(FIXTURE_PATH, 'HelloWorld.apk')
})
end").runner.execute(:test)
expect(ENV['BROWSERSTACK_LIVE_APP_ID']).to eq(custom_id)
end
end
end