Skip to content

Commit 389decb

Browse files
committed
tidy up cli arg creation
1 parent 07fd4a3 commit 389decb

File tree

4 files changed

+59
-56
lines changed

4 files changed

+59
-56
lines changed

tools/fastlane-plugin/lib/fastlane/plugin/bugsnag/actions/bugsnag_cli.rb

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ def self.get_bugsnag_cli_path(params)
1414
if bugsnag_cli_version < bundled_bugsnag_cli_version
1515
FastlaneCore::UI.warning("The installed bugsnag-cli at #{bugsnag_cli_path} is outdated (#{bugsnag_cli_version}). The current bundled version is: #{bundled_bugsnag_cli_version}. It is recommended that you either update your installed version or use the bundled version.")
1616
end
17+
FastlaneCore::UI.verbose("Using bugsnag-cli from path: #{bugsnag_cli_path}")
1718
bugsnag_cli_path
1819
else
20+
FastlaneCore::UI.verbose("Using bundled bugsnag-cli from path: #{bundled_bugsnag_cli_path}")
1921
bundled_bugsnag_cli_path
2022
end
2123
end
@@ -48,4 +50,55 @@ def self.get_bundled_path
4850
def self.bin_folder(filename)
4951
File.expand_path("../../../../../bin/#{filename}", File.dirname(__FILE__))
5052
end
53+
54+
def self.create_build_args(api_key, version_name, version_code, bundle_version, release_stage, builder, revision, repository, provider, auto_assign_release, metadata, retries, timeout, endpoint)
55+
args = []
56+
args += ["--api-key", api_key] unless api_key.nil?
57+
args += ["--version-name", version_name] unless version_name.nil?
58+
args += ["--version-code", version_code] unless version_code.nil?
59+
args += ["--bundle-version", bundle_version] unless bundle_version.nil?
60+
args += ["--release-stage", release_stage] unless release_stage.nil?
61+
args += ["--builder-name", builder] unless builder.nil?
62+
args += ["--revision", revision] unless revision.nil?
63+
args += ["--repository", repository] unless repository.nil?
64+
args += ["--provider", provider] unless provider.nil?
65+
args += ["--auto-assign-release"] if auto_assign_release
66+
unless metadata.nil?
67+
if metadata.is_a?(String)
68+
#
69+
args += ["--metadata", metadata]
70+
elsif metadata.is_a?(Hash)
71+
formatted_metadata = metadata.map { |k, v| %Q{"#{k}"="#{v}"} }.join(",")
72+
args += ["--metadata", formatted_metadata]
73+
end
74+
end
75+
args += ["--retries", retries] unless retries.nil?
76+
args += ["--timeout", timeout] unless timeout.nil?
77+
args += ["--build-api-root-url", endpoint] unless endpoint.nil?
78+
args += ["--verbose"] if FastlaneCore::Globals.verbose?
79+
args
80+
end
81+
82+
def self.upload_args dir, upload_url, project_root, api_key, ignore_missing_dwarf, ignore_empty_dsym, dryrun, log_level, port, retries, timeout, configuration, scheme, plist, xcode_project
83+
args = []
84+
args += ["--verbose"] if FastlaneCore::Globals.verbose?
85+
args += ["--ignore-missing-dwarf"] if ignore_missing_dwarf
86+
args += ["--ignore-empty-dsym"] if ignore_empty_dsym
87+
args += ["--api-key", api_key] unless api_key.nil?
88+
args += ["--upload-api-root-url", upload_url] unless upload_url.nil?
89+
args += ["--project-root", project_root] unless project_root.nil?
90+
args += ["--dry-run"] if dryrun
91+
args += ["--log-level", log_level] unless log_level.nil?
92+
args += ["--port", port] unless port.nil?
93+
args += ["--retries", retries] unless retries.nil?
94+
args += ["--timeout", timeout] unless timeout.nil?
95+
args += ["--configuration", configuration] unless configuration.nil?
96+
args += ["--scheme", scheme] unless scheme.nil?
97+
args += ["--plist", plist] unless plist.nil?
98+
args += ["--xcode-project", xcode_project] unless xcode_project.nil?
99+
args << dir
100+
args
101+
end
51102
end
103+
104+

tools/fastlane-plugin/lib/fastlane/plugin/bugsnag/actions/send_build_to_bugsnag.rb

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ module Actions
88
class SendBuildToBugsnagAction < Action
99
def self.run(params)
1010
bugsnag_cli_path = BugsnagCli.get_bugsnag_cli_path(params)
11-
verbose = UI.verbose("Using bugsnag-cli from path: #{bugsnag_cli_path}")
1211

1312
# If a configuration file was found or was specified, load in the options:
1413
config_options = {}
@@ -40,7 +39,7 @@ def self.run(params)
4039
UI.user_error! missing_app_version_message(params)
4140
end
4241

43-
args = create_build_args(
42+
args = BugsnagCli.create_build_args(
4443
api_key,
4544
version_name,
4645
version_code,
@@ -54,8 +53,7 @@ def self.run(params)
5453
metadata,
5554
retries,
5655
timeout,
57-
endpoint,
58-
verbose
56+
endpoint
5957
)
6058
bugsnag_cli_command = "#{bugsnag_cli_path} create-build #{args.join(' ')}"
6159
UI.verbose("Running command: #{bugsnag_cli_command}")
@@ -67,34 +65,6 @@ def self.run(params)
6765
end
6866
end
6967

70-
def self.create_build_args(api_key, version_name, version_code, bundle_version, release_stage, builder, revision, repository, provider, auto_assign_release, metadata, retries, timeout, endpoint, verbose)
71-
args = []
72-
args += ["--api-key", api_key] unless api_key.nil?
73-
args += ["--version-name", version_name] unless version_name.nil?
74-
args += ["--version-code", version_code] unless version_code.nil?
75-
args += ["--bundle-version", bundle_version] unless bundle_version.nil?
76-
args += ["--release-stage", release_stage] unless release_stage.nil?
77-
args += ["--builder-name", builder] unless builder.nil?
78-
args += ["--revision", revision] unless revision.nil?
79-
args += ["--repository", repository] unless repository.nil?
80-
args += ["--provider", provider] unless provider.nil?
81-
args += ["--auto-assign-release"] if auto_assign_release
82-
unless metadata.nil?
83-
if metadata.is_a?(String)
84-
#
85-
args += ["--metadata", metadata]
86-
elsif metadata.is_a?(Hash)
87-
formatted_metadata = metadata.map { |k, v| %Q{"#{k}"="#{v}"} }.join(",")
88-
args += ["--metadata", formatted_metadata]
89-
end
90-
end
91-
args += ["--retries", retries] unless retries.nil?
92-
args += ["--timeout", timeout] unless timeout.nil?
93-
args += ["--build-api-root-url", endpoint] unless endpoint.nil?
94-
args += ["--verbose"] if verbose
95-
args
96-
end
97-
9868
def self.missing_api_key_message(params)
9969
message = "A Bugsnag API key is required to release a build. "
10070
if lane_context[:PLATFORM_NAME] == :android

tools/fastlane-plugin/lib/fastlane/plugin/bugsnag/actions/upload_symbols_to_bugsnag.rb

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def self.run(params)
1919

2020
# If verbose flag is enabled (`--verbose`), display the plugin action debug info
2121
# Store the verbose flag for use in the upload arguments.
22-
verbose = UI.verbose("Uploading dSYMs to Bugsnag with the following parameters:")
22+
UI.verbose("Uploading dSYMs to Bugsnag with the following parameters:")
2323
rjust = 30 # set justification width for keys for the list of parameters to output
2424
params.values.each do |param|
2525
UI.verbose(" #{param[0].to_s.rjust(rjust)}: #{param[1]}")
@@ -29,12 +29,11 @@ def self.run(params)
2929

3030
parse_dsym_paths(params[:dsym_path]).each do |dsym_path|
3131
if dsym_path.end_with?(".zip") or File.directory?(dsym_path)
32-
args = upload_args(
32+
args = BugsnagCli.upload_args(
3333
"\"#{dsym_path}\"",
3434
params[:upload_url],
3535
params[:project_root],
3636
api_key,
37-
verbose,
3837
params[:ignore_missing_dwarf],
3938
params[:ignore_empty_dsym],
4039
params[:dryrun],
@@ -212,26 +211,7 @@ def self.options_from_info_plist file_path
212211
}
213212
end
214213

215-
def self.upload_args dir, upload_url, project_root, api_key, verbose, ignore_missing_dwarf, ignore_empty_dsym, dryrun, log_level, port, retries, timeout, configuration, scheme, plist, xcode_project
216-
args = []
217-
args += ["--verbose"] if verbose
218-
args += ["--ignore-missing-dwarf"] if ignore_missing_dwarf
219-
args += ["--ignore-empty-dsym"] if ignore_empty_dsym
220-
args += ["--api-key", api_key] unless api_key.nil?
221-
args += ["--upload-api-root-url", upload_url] unless upload_url.nil?
222-
args += ["--project-root", project_root] unless project_root.nil?
223-
args += ["--dry-run"] if dryrun
224-
args += ["--log-level", log_level] unless log_level.nil?
225-
args += ["--port", port] unless port.nil?
226-
args += ["--retries", retries] unless retries.nil?
227-
args += ["--timeout", timeout] unless timeout.nil?
228-
args += ["--configuration", configuration] unless configuration.nil?
229-
args += ["--scheme", scheme] unless scheme.nil?
230-
args += ["--plist", plist] unless plist.nil?
231-
args += ["--xcode-project", xcode_project] unless xcode_project.nil?
232-
args << dir
233-
args
234-
end
214+
235215

236216
# returns an array of unique dSYM-containing directory paths to upload
237217
def self.parse_dsym_paths dsym_path

tools/fastlane-plugin/spec/bugsnag_upload_dsym_action_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def run_with args
167167
allow(Fastlane::Actions::UploadSymbolsToBugsnagAction).to receive(:version_from_cli).and_return("1.0.0")
168168
allow(Fastlane::Actions::UploadSymbolsToBugsnagAction).to receive(:bundled_bugsnag_cli_version).and_return(bundled_bugsnag_cli_version)
169169

170-
expect(Fastlane::UI).to receive(:warning).with("Your bugsnag-cli is outdated. The current bugsnag-cli version is: #{bundled_bugsnag_cli_version}")
170+
expect(Fastlane::UI).to receive(:warning).with("The installed bugsnag-cli at #{cli_path} is outdated (1.0.0). The current bundled version is: #{bundled_bugsnag_cli_version}. It is recommended that you either update your installed version or use the bundled version.")
171171
expect(Kernel).to receive(:system).with("#{cli_path} upload dsym --project-root #{Dir::pwd} \"#{FIXTURE_PATH}\"").and_return(true)
172172

173173
run_with({dsym_path: FIXTURE_PATH, bugsnag_cli_path: cli_path})

0 commit comments

Comments
 (0)