Class: Fastlane::Actions::AppdynamicsAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/appdynamics/actions/appdynamics_action.rb

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



140
141
142
# File 'lib/fastlane/plugin/appdynamics/actions/appdynamics_action.rb', line 140

def self.authors
  ["wedkarz"]
end

.available_optionsObject



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
# File 'lib/fastlane/plugin/appdynamics/actions/appdynamics_action.rb', line 88

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :api_host,
                                 env_name: "APPDYNAMICS_HOST",
                                 description: "API host url for AppDynamics",
                                 default_value: "https://api.eum-appdynamics.com",
                                 is_string: true,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :api_account_name,
                                 env_name: "APPDYNAMICS_ACCOUNT_NAME",
                                 description: "Account name for AppDynamics",
                                 is_string: true,
                                 optional: false,
                                 verify_block: proc do |value|
                                   UI.user_error!("No account name for AppDynamics given, pass using `api_account_name: 'name'`") if value.to_s.length == 0
                                 end),
    FastlaneCore::ConfigItem.new(key: :api_license_key,
                                 env_name: "APPDYNAMICS_LICENSE_KEY",
                                 description: "License key for AppDynamics",
                                 sensitive: true,
                                 optional: false,
                                 verify_block: proc do |value|
                                   UI.user_error!("No license key for AppDynamics given, pass using `api_license_key: 'key'`") if value.to_s.length == 0
                                 end),
    FastlaneCore::ConfigItem.new(key: :dsym_path,
                                 env_name: "APPDYNAMICS_DSYM_PATH",
                                 description: "Path to your symbols file. For iOS and Mac provide path to app.dSYM.zip",
                                 default_value: Actions.lane_context[SharedValues::DSYM_OUTPUT_PATH.to_sym],
                                 optional: true,
                                 verify_block: proc do |value|
                                   # validation is done in the action
                                 end),
    FastlaneCore::ConfigItem.new(key: :dsym_paths,
                                 env_name: "APPDYNAMICS_DSYM_PATHS",
                                 description: "Path to an array of your symbols file. For iOS and Mac provide path to app.dSYM.zip",
                                 default_value: Actions.lane_context[SharedValues::DSYM_PATHS.to_sym],
                                 is_string: false,
                                 optional: true,
                                 verify_block: proc do |value|
                                   # validation is done in the action
                                 end)
  ]
end

.connection(host, api_account_name, api_license_key) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fastlane/plugin/appdynamics/actions/appdynamics_action.rb', line 4

def self.connection(host, , api_license_key)
  require 'faraday'
  require 'faraday_middleware'

  base_url = "#{host}/eumaggregator/crash-reports/iOSDSym"
  foptions = {
    url: base_url
  }
  Faraday.new(foptions) do |builder|
    builder.request :basic_auth, , api_license_key
    builder.use FaradayMiddleware::FollowRedirects
    builder.adapter :net_http
  end
end

.descriptionObject



76
77
78
# File 'lib/fastlane/plugin/appdynamics/actions/appdynamics_action.rb', line 76

def self.description
  "Upload dSYM symbolication files to AppDynamics"
end

.detailsObject



80
81
82
83
84
85
86
# File 'lib/fastlane/plugin/appdynamics/actions/appdynamics_action.rb', line 80

def self.details
  [
    "This action allows you to upload symbolication files to AppDynamics.",
    "It's extra useful if you use it to download the latest dSYM files from Apple when you",
    "use Bitcode."
  ].join(" ")
end

.example_codeObject



148
149
150
151
152
153
154
155
156
# File 'lib/fastlane/plugin/appdynamics/actions/appdynamics_action.rb', line 148

def self.example_code
  [
    'appdynamics(
      api_account_name: "...",
      api_license_key: "...",
      dsym_path: "./App.dSYM.zip"
    )'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


144
145
146
# File 'lib/fastlane/plugin/appdynamics/actions/appdynamics_action.rb', line 144

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

.outputObject



132
133
134
# File 'lib/fastlane/plugin/appdynamics/actions/appdynamics_action.rb', line 132

def self.output
  nil
end

.return_valueObject



136
137
138
# File 'lib/fastlane/plugin/appdynamics/actions/appdynamics_action.rb', line 136

def self.return_value
  nil
end

.run(params) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/fastlane/plugin/appdynamics/actions/appdynamics_action.rb', line 19

def self.run(params)
  Actions.verify_gem!('faraday')
  Actions.verify_gem!('faraday_middleware')

  # Params - API
  host = params[:api_host]
   = params[:api_account_name]
  api_license_key = params[:api_license_key]

   = !.to_s.empty?
  has_license_key = !api_license_key.to_s.empty?

  if ! || !has_license_key
    UI.user_error!("No account name or license key found for AppDynamics, pass using `api_account_name: 'name'` and `api_license_key: 'key'`")
  end

  # Params - dSYM
  dsym_path = params[:dsym_path]
  dsym_zip_path = Actions.lane_context[SharedValues::DSYM_ZIP_PATH.to_sym]
  dsym_paths = params[:dsym_paths] || []
  dsym_paths += [dsym_path] unless dsym_path.nil?
  dsym_paths += [dsym_zip_path] unless dsym_zip_path.nil?

  # Verify dsym(s)
  dsym_paths = dsym_paths.map { |path| File.absolute_path(path) }
  dsym_paths.each do |path|
    UI.user_error!("dSYM does not exist at path: #{path}") unless File.exist? path
  end

  # Upload dsym(s)
  dsym_paths.compact.map do |dsym|
    upload_dsym(dsym, host, , api_license_key)
  end

  UI.success 'dSYMs successfully uploaded to AppDynamics!'
end

.upload_dsym(dsym, host, api_account_name, api_license_key) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/fastlane/plugin/appdynamics/actions/appdynamics_action.rb', line 56

def self.upload_dsym(dsym, host, , api_license_key)
  UI.message "Uploading #{dsym}"
  connection = self.connection(host, , api_license_key)

  response = connection.put do |request|
    content_type = 'application/octet-stream'
    request.headers[:content_type] = content_type
    request.headers[:content_length] = File.size(dsym).to_s
    request.body = Faraday::UploadIO.new(dsym, content_type)
  end

  puts response
rescue Exception => exception
  UI.user_error! "Error while trying to upload dSYM to AppDynamics: #{exception}"
end