From c4d2ecf5fc2c0b76a55110a191d6899580e40b0d Mon Sep 17 00:00:00 2001 From: Alex Sergeev Date: Fri, 29 May 2026 13:17:56 +0200 Subject: [PATCH] feat: add custom_id support to upload_to_browserstack_app_live action --- README.md | 6 +++++- .../upload_to_browserstack_app_live_action.rb | 9 +++++++-- ...pload_to_browserstack_app_live_action_spec.rb | 16 ++++++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 78a674a..a9c6f9c 100644 --- a/README.md +++ b/README.md @@ -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: "" + file_path: "", + custom_id: "" ) ``` +``` +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 : diff --git a/lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_live_action.rb b/lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_live_action.rb index 30ea8ce..f80ce39 100644 --- a/lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_live_action.rb +++ b/lib/fastlane/plugin/browserstack/actions/upload_to_browserstack_app_live_action.rb @@ -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 @@ -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 diff --git a/spec/upload_to_browserstack_app_live_action_spec.rb b/spec/upload_to_browserstack_app_live_action_spec.rb index a425fbb..f7cb92a 100644 --- a/spec/upload_to_browserstack_app_live_action_spec.rb +++ b/spec/upload_to_browserstack_app_live_action_spec.rb @@ -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 @@ -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