Skip to content

Commit 076ad2b

Browse files
committed
fix-extracting-instabug-params-from-fastlane-params
1 parent 5048fe7 commit 076ad2b

File tree

6 files changed

+51
-12
lines changed

6 files changed

+51
-12
lines changed

lib/fastlane/plugin/instabug_stores_upload/actions/instabug_build_android_app_action.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ def self.run(params)
88
UI.message("Starting Instabug Android build...")
99

1010
# Extract Instabug-specific parameters
11-
branch_name = params.delete(:branch_name)
12-
instabug_api_key = params.delete(:instabug_api_key)
11+
branch_name = params[:branch_name]
12+
instabug_api_key = params[:instabug_api_key]
1313

1414
# Validate required parameters
1515
if branch_name.nil? || branch_name.empty?
1616
UI.user_error!("branch_name is required for Instabug reporting")
1717
end
1818

19+
# Filter out Instabug-specific parameters before passing to gradle
20+
filtered_params = Helper::InstabugStoresUploadHelper.filter_instabug_params(params, Actions::GradleAction)
21+
1922
begin
2023
# Report build start to Instabug
2124
Helper::InstabugStoresUploadHelper.report_status(
@@ -29,7 +32,7 @@ def self.run(params)
2932
build_start_time = Time.now
3033

3134
# Execute the actual Android build using gradle
32-
result = Actions::GradleAction.run(params)
35+
result = Actions::GradleAction.run(filtered_params)
3336

3437
# Calculate build time in seconds
3538
build_time = (Time.now - build_start_time).round

lib/fastlane/plugin/instabug_stores_upload/actions/instabug_build_ios_app_action.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ def self.run(params)
88
UI.message("Starting Instabug iOS build...")
99

1010
# Extract Instabug-specific parameters
11-
branch_name = params.delete(:branch_name)
12-
instabug_api_key = params.delete(:instabug_api_key)
11+
branch_name = params[:branch_name]
12+
instabug_api_key = params[:instabug_api_key]
1313

1414
# Validate required parameters
1515
if branch_name.nil? || branch_name.empty?
1616
UI.user_error!("branch_name is required for Instabug reporting")
1717
end
1818

19+
# Filter out Instabug-specific parameters before passing to build_ios_app
20+
filtered_params = Helper::InstabugStoresUploadHelper.filter_instabug_params(params, Actions::BuildIosAppAction)
21+
1922
begin
2023
# Report build start to Instabug
2124
Helper::InstabugStoresUploadHelper.report_status(
@@ -29,7 +32,7 @@ def self.run(params)
2932
build_start_time = Time.now
3033

3134
# Execute the actual iOS build
32-
result = Actions::BuildIosAppAction.run(params)
35+
result = Actions::BuildIosAppAction.run(filtered_params)
3336

3437
# Calculate build time in seconds
3538
build_time = (Time.now - build_start_time).round

lib/fastlane/plugin/instabug_stores_upload/actions/instabug_upload_to_app_store_action.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ def self.run(params)
88
UI.message("Starting Instabug App Store upload...")
99

1010
# Extract Instabug-specific parameters
11-
branch_name = params.delete(:branch_name)
12-
instabug_api_key = params.delete(:instabug_api_key)
11+
branch_name = params[:branch_name]
12+
instabug_api_key = params[:instabug_api_key]
1313

1414
# Validate required parameters
1515
if branch_name.nil? || branch_name.empty?
1616
UI.user_error!("branch_name is required for Instabug reporting")
1717
end
1818

19+
# Filter out Instabug-specific parameters before passing to upload_to_app_store
20+
filtered_params = Helper::InstabugStoresUploadHelper.filter_instabug_params(params, Actions::UploadToAppStoreAction)
21+
1922
begin
2023
# Report upload start to Instabug
2124
Helper::InstabugStoresUploadHelper.report_status(
@@ -26,7 +29,7 @@ def self.run(params)
2629
)
2730

2831
# Execute the actual upload to App Store
29-
result = Actions::UploadToAppStoreAction.run(params)
32+
result = Actions::UploadToAppStoreAction.run(filtered_params)
3033

3134
# Report upload success to Instabug
3235
Helper::InstabugStoresUploadHelper.report_status(

lib/fastlane/plugin/instabug_stores_upload/actions/instabug_upload_to_play_store_action.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ def self.run(params)
88
UI.message("Starting Instabug Play Store upload...")
99

1010
# Extract Instabug-specific parameters
11-
branch_name = params.delete(:branch_name)
12-
instabug_api_key = params.delete(:instabug_api_key)
11+
branch_name = params[:branch_name]
12+
instabug_api_key = params[:instabug_api_key]
1313

1414
# Validate required parameters
1515
if branch_name.nil? || branch_name.empty?
1616
UI.user_error!("branch_name is required for Instabug reporting")
1717
end
1818

19+
# Filter out Instabug-specific parameters before passing to upload_to_play_store
20+
filtered_params = Helper::InstabugStoresUploadHelper.filter_instabug_params(params, Actions::UploadToPlayStoreAction)
21+
1922
begin
2023
# Report upload start to Instabug
2124
Helper::InstabugStoresUploadHelper.report_status(
@@ -26,7 +29,7 @@ def self.run(params)
2629
)
2730

2831
# Execute the actual upload to Play Store
29-
result = Actions::UploadToPlayStoreAction.run(params)
32+
result = Actions::UploadToPlayStoreAction.run(filtered_params)
3033

3134
# Report upload success to Instabug
3235
Helper::InstabugStoresUploadHelper.report_status(

lib/fastlane/plugin/instabug_stores_upload/helper/instabug_stores_upload_helper.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,30 @@ module Helper
1010
class InstabugStoresUploadHelper
1111
# Default Base URL for Instabug API
1212
DEFAULT_INSTABUG_API_BASE_URL = "https://api.instabug.com".freeze
13+
INSTABUG_KEYS = %i[branch_name instabug_api_key instabug_api_base_url].freeze
1314

1415
def self.show_message
1516
UI.message("Hello from the instabug_stores_upload plugin helper!")
1617
end
1718

19+
# Filters out Instabug-specific parameters from the params configuration
20+
# and returns a new FastlaneCore::Configuration object with only the target action's parameters
21+
def self.filter_instabug_params(params, target_action_class)
22+
filtered_config = {}
23+
params.available_options.each do |option|
24+
key = option.key
25+
unless INSTABUG_KEYS.include?(key)
26+
value = params[key]
27+
filtered_config[key] = value if value
28+
end
29+
end
30+
31+
FastlaneCore::Configuration.create(
32+
target_action_class.available_options,
33+
filtered_config
34+
)
35+
end
36+
1837
def self.report_status(branch_name:, api_key:, status:, step:, extras: {}, error_message: nil)
1938
return unless branch_name.start_with?('crash-fix/instabug-crash-')
2039

spec/spec_helper.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ module SpecHelper
1313
require 'fastlane/plugin/instabug_stores_upload' # import the actual plugin
1414
require 'webmock/rspec'
1515

16+
# Override the helper method for tests to handle plain hashes
17+
class Fastlane::Helper::InstabugStoresUploadHelper
18+
def self.filter_instabug_params(params, target_action_class)
19+
# In test environment, params are plain hashes - just filter them
20+
return params.reject { |key, _value| INSTABUG_KEYS.include?(key) }
21+
end
22+
end
23+
1624
Fastlane.load_actions # load other actions (in case your plugin calls other actions or shared values)
1725

1826
WebMock.disable_net_connect!(allow_localhost: true)

0 commit comments

Comments
 (0)