Class: Fastlane::Actions::SplunkmintAction

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

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, details, output, return_value, sh, step_text

Class Method Details

.authorsObject



115
116
117
# File 'lib/fastlane/actions/splunkmint.rb', line 115

def self.authors
  ["xfreebird"]
end

.available_optionsObject



76
77
78
79
80
81
82
83
84
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
# File 'lib/fastlane/actions/splunkmint.rb', line 76

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",
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :api_token,
                                 env_name: "FL_SPLUNKMINT_API_TOKEN",
                                 description: "Splunk MINT API token e.g. e05ba40754c4869fb7e0b61",
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :verbose,
                                 env_name: "FL_SPLUNKMINT_VERBOSE",
                                 description: "Make detailed output",
                                 is_string: false,
                                 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",
                                 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

.descriptionObject



72
73
74
# File 'lib/fastlane/actions/splunkmint.rb', line 72

def self.description
  "Upload dSYM file to Splunk MINT"
end

.dsym_path(params) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/fastlane/actions/splunkmint.rb', line 32

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)
    raise "Couldn't find file at path '#{expanded_file_path}'".red unless File.exist?(expanded_file_path)

    return expanded_file_path
  else
    raise "Couldn't find any dSYM file".red
  end
end

.fail_on_error(result) ⇒ Object



18
19
20
21
22
# File 'lib/fastlane/actions/splunkmint.rb', line 18

def self.fail_on_error(result)
  if result.include?("error") || result.include?("Excess found")
    raise "Server error, failed to upload the dSYM file".red
  end
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


119
120
121
# File 'lib/fastlane/actions/splunkmint.rb', line 119

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

.proxy_options(params) ⇒ Object



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

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
# File '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

  result = Fastlane::Actions.sh(command.join(' '), log: false)
  fail_on_error(result)

  result
end

.upload_options(params) ⇒ Object



47
48
49
50
51
52
53
54
55
56
# File 'lib/fastlane/actions/splunkmint.rb', line 47

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_urlObject



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

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

.verbose(params) ⇒ Object



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

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