Class: BugsnagCli

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/bugsnag/actions/bugsnag_cli.rb

Class Method Summary collapse

Class Method Details

.bin_folder(filename) ⇒ Object



50
51
52
# File 'lib/fastlane/plugin/bugsnag/actions/bugsnag_cli.rb', line 50

def self.bin_folder(filename)
  File.expand_path("../../../../../bin/#{filename}", File.dirname(__FILE__))
end

.create_build(cli_path, args) ⇒ Object



109
110
111
112
113
# File 'lib/fastlane/plugin/bugsnag/actions/bugsnag_cli.rb', line 109

def self.create_build cli_path, args
  bugsnag_cli_command = "#{cli_path} create-build #{args.join(' ')}"
  FastlaneCore::UI.verbose("Running command: #{bugsnag_cli_command}")
  Kernel.system(bugsnag_cli_command)
end

.create_build_args(api_key, version_name, version_code, bundle_version, release_stage, builder, revision, repository, provider, auto_assign_release, metadata, retries, timeout, endpoint) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/fastlane/plugin/bugsnag/actions/bugsnag_cli.rb', line 54

def self.create_build_args(api_key, version_name, version_code, bundle_version, release_stage, builder, revision, repository, provider, auto_assign_release, , retries, timeout, endpoint)
  args = []
  args += ["--api-key", api_key] unless api_key.nil?
  args += ["--version-name", version_name] unless version_name.nil?
  args += ["--version-code", version_code] unless version_code.nil?
  args += ["--bundle-version", bundle_version] unless bundle_version.nil?
  args += ["--release-stage", release_stage] unless release_stage.nil?
  args += ["--builder-name", builder] unless builder.nil?
  args += ["--revision", revision] unless revision.nil?
  args += ["--repository", repository] unless repository.nil?
  args += ["--provider", provider] unless provider.nil?
  args += ["--auto-assign-release"] if auto_assign_release
  unless .nil?
    if .is_a?(String)
      #
      args += ["--metadata", ]
    elsif .is_a?(Hash)
       = .map { |k, v| %Q{"#{k}"="#{v}"} }.join(",")
      args += ["--metadata", ]
    end
  end
  args += ["--retries", retries] unless retries.nil?
  args += ["--timeout", timeout] unless timeout.nil?
  args += ["--build-api-root-url", endpoint] unless endpoint.nil?
  args += ["--verbose"] if FastlaneCore::Globals.verbose?
  args
end

.get_bugsnag_cli_path(params) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fastlane/plugin/bugsnag/actions/bugsnag_cli.rb', line 5

def self.get_bugsnag_cli_path(params)
  bundled_bugsnag_cli_path = self.get_bundled_path
  bundled_bugsnag_cli_version = Gem::Version.new(`#{bundled_bugsnag_cli_path} --version`.scan(/(?:\d+\.?){3}/).first)

  if params[:bugsnag_cli_path]
    bugsnag_cli_path = params[:bugsnag_cli_path] || bundled_bugsnag_cli_path

    bugsnag_cli_version = Gem::Version.new(`#{bugsnag_cli_path} --version`.scan(/(?:\d+\.?){3}/).first)

    if bugsnag_cli_version < bundled_bugsnag_cli_version
      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.")
    end
    FastlaneCore::UI.verbose("Using bugsnag-cli from path: #{bugsnag_cli_path}")
    bugsnag_cli_path
  else
    FastlaneCore::UI.verbose("Using bundled bugsnag-cli from path: #{bundled_bugsnag_cli_path}")
    bundled_bugsnag_cli_path
  end
end

.get_bundled_pathObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fastlane/plugin/bugsnag/actions/bugsnag_cli.rb', line 25

def self.get_bundled_path
  host_cpu = RbConfig::CONFIG['host_cpu']
  if OS.mac?
    if host_cpu =~ /arm|aarch64/
      self.bin_folder('arm64-macos-bugsnag-cli')
    else
      self.bin_folder('x86_64-macos-bugsnag-cli')
    end
  elsif OS.windows?
    if OS.bits == 64
      self.bin_folder('x86_64-windows-bugsnag-cli.exe')
    else
      self.bin_folder('i386-windows-bugsnag-cli.exe')
    end
  else
    if host_cpu =~ /arm|aarch64/
      self.bin_folder('arm64-linux-bugsnag-cli')
    elsif OS.bits == 64
      self.bin_folder('x86_64-linux-bugsnag-cli')
    else
      self.bin_folder('i386-linux-bugsnag-cli')
    end
  end
end

.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) ⇒ Object



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/fastlane/plugin/bugsnag/actions/bugsnag_cli.rb', line 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
  args = []
  args += ["--verbose"] if FastlaneCore::Globals.verbose?
  args += ["--ignore-missing-dwarf"] if ignore_missing_dwarf
  args += ["--ignore-empty-dsym"] if ignore_empty_dsym
  args += ["--api-key", api_key] unless api_key.nil?
  args += ["--upload-api-root-url", upload_url] unless upload_url.nil?
  args += ["--project-root", project_root] unless project_root.nil?
  args += ["--dry-run"] if dryrun
  args += ["--log-level", log_level] unless log_level.nil?
  args += ["--port", port] unless port.nil?
  args += ["--retries", retries] unless retries.nil?
  args += ["--timeout", timeout] unless timeout.nil?
  args += ["--configuration", configuration] unless configuration.nil?
  args += ["--scheme", scheme] unless scheme.nil?
  args += ["--plist", plist] unless plist.nil?
  args += ["--xcode-project", xcode_project] unless xcode_project.nil?
  args << dir
  args
end

.upload_dsym(cli_path, args) ⇒ Object



103
104
105
106
107
# File 'lib/fastlane/plugin/bugsnag/actions/bugsnag_cli.rb', line 103

def self.upload_dsym cli_path, args
  bugsnag_cli_command = "#{cli_path} upload dsym #{args.join(' ')}"
  FastlaneCore::UI.verbose("Running command: #{bugsnag_cli_command}")
  Kernel.system(bugsnag_cli_command)
end