Class: Fastlane::Actions::SplunkmintAction

Inherits:
Fastlane::Action show all
Defined in:
fastlane/lib/fastlane/actions/splunkmint.rb

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, deprecated_notes, details, lane_context, method_missing, other_action, output, return_type, return_value, sample_return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.authorsObject



133
134
135
# File 'fastlane/lib/fastlane/actions/splunkmint.rb', line 133

def self.authors
  ["xfreebird"]
end

.available_optionsObject



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'fastlane/lib/fastlane/actions/splunkmint.rb', line 85

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :dsym,
                                 env_name: "FL_SPLUNKMINT_FILE",
                                 description: "dSYM.zip file to upload to Splunk MINT",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :api_key,
                                 env_name: "FL_SPLUNKMINT_API_KEY",
                                 description: "Splunk MINT App API key e.g. f57a57ca",
                                 sensitive: true,
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :api_token,
                                 env_name: "FL_SPLUNKMINT_API_TOKEN",
                                 description: "Splunk MINT API token e.g. e05ba40754c4869fb7e0b61",
                                 sensitive: true,
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :verbose,
                                 env_name: "FL_SPLUNKMINT_VERBOSE",
                                 description: "Make detailed output",
                                 type: Boolean,
                                 default_value: false,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :upload_progress,
                                 env_name: "FL_SPLUNKMINT_UPLOAD_PROGRESS",
                                 description: "Show upload progress",
                                 type: Boolean,
                                 default_value: false,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :proxy_username,
                                 env_name: "FL_SPLUNKMINT_PROXY_USERNAME",
                                 description: "Proxy username",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :proxy_password,
                                 env_name: "FL_SPLUNKMINT_PROXY_PASSWORD",
                                 sensitive: true,
                                 description: "Proxy password",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :proxy_address,
                                 env_name: "FL_SPLUNKMINT_PROXY_ADDRESS",
                                 description: "Proxy address",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :proxy_port,
                                 env_name: "FL_SPLUNKMINT_PROXY_PORT",
                                 description: "Proxy port",
                                 optional: true)
  ]
end

.categoryObject



151
152
153
# File 'fastlane/lib/fastlane/actions/splunkmint.rb', line 151

def self.category
  :beta
end

.descriptionObject



81
82
83
# File 'fastlane/lib/fastlane/actions/splunkmint.rb', line 81

def self.description
  "Upload dSYM file to [Splunk MINT](https://mint.splunk.com/)"
end

.dsym_path(params) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'fastlane/lib/fastlane/actions/splunkmint.rb', line 41

def self.dsym_path(params)
  file_path = params[:dsym]
  file_path ||= Actions.lane_context[SharedValues::DSYM_OUTPUT_PATH] || ENV[SharedValues::DSYM_OUTPUT_PATH.to_s]
  file_path ||= Actions.lane_context[SharedValues::DSYM_ZIP_PATH] || ENV[SharedValues::DSYM_ZIP_PATH.to_s]

  if file_path
    expanded_file_path = File.expand_path(file_path)
    UI.user_error!("Couldn't find file at path '#{expanded_file_path}'") unless File.exist?(expanded_file_path)

    return expanded_file_path
  else
    UI.user_error!("Couldn't find any dSYM file")
  end
end

.example_codeObject



141
142
143
144
145
146
147
148
149
# File 'fastlane/lib/fastlane/actions/splunkmint.rb', line 141

def self.example_code
  [
    'splunkmint(
      dsym: "My.app.dSYM.zip",
      api_key: "43564d3a",
      api_token: "e05456234c4869fb7e0b61"
    )'
  ]
end

.fail_on_error(result) ⇒ Object



23
24
25
26
27
# File 'fastlane/lib/fastlane/actions/splunkmint.rb', line 23

def self.fail_on_error(result)
  if result.include?("error")
    UI.user_error!("Server error, failed to upload the dSYM file")
  end
end

.is_supported?(platform) ⇒ Boolean

Returns:



137
138
139
# File 'fastlane/lib/fastlane/actions/splunkmint.rb', line 137

def self.is_supported?(platform)
  platform == :ios
end

.proxy_options(params) ⇒ Object



67
68
69
70
71
72
73
74
75
# File 'fastlane/lib/fastlane/actions/splunkmint.rb', line 67

def self.proxy_options(params)
  options = []
  if params[:proxy_address] && params[:proxy_port] && params[:proxy_username] && params[:proxy_password]
    options << "-x #{params[:proxy_address].shellescape}:#{params[:proxy_port].shellescape}"
    options << "--proxy-user #{params[:proxy_username].shellescape}:#{params[:proxy_password].shellescape}"
  end

  options
end

.run(params) ⇒ Object



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

def self.run(params)
  command = []
  command << "curl"
  command << verbose(params)
  command += proxy_options(params)
  command += upload_options(params)
  command << upload_url
  command << upload_progress(params)

  # Fastlane::Actions.sh has buffering issues, no progress bar is shown in real time
  # will reanable it when it is fixed
  # result = Fastlane::Actions.sh(command.join(' '), log: false)
  shell_command = command.join(' ')
  result = Helper.test? ? shell_command : `#{shell_command}`
  fail_on_error(result)

  result
end

.upload_options(params) ⇒ Object



56
57
58
59
60
61
62
63
64
65
# File 'fastlane/lib/fastlane/actions/splunkmint.rb', line 56

def self.upload_options(params)
  file_path = dsym_path(params).shellescape

  options = []
  options << "-F file=@#{file_path}"
  options << "--header 'X-Splunk-Mint-Auth-Token: #{params[:api_token].shellescape}'"
  options << "--header 'X-Splunk-Mint-apikey: #{params[:api_key].shellescape}'"

  options
end

.upload_progress(params) ⇒ Object



37
38
39
# File 'fastlane/lib/fastlane/actions/splunkmint.rb', line 37

def self.upload_progress(params)
  params[:upload_progress] ? " --progress-bar -o /dev/null --no-buffer" : ""
end

.upload_urlObject



29
30
31
# File 'fastlane/lib/fastlane/actions/splunkmint.rb', line 29

def self.upload_url
  "https://ios.splkmobile.com/api/v1/dsyms/upload"
end

.verbose(params) ⇒ Object



33
34
35
# File 'fastlane/lib/fastlane/actions/splunkmint.rb', line 33

def self.verbose(params)
  params[:verbose] ? "--verbose" : ""
end