Class: Fastlane::Actions::ZealotDebugFileAction

Inherits:
Action
  • Object
show all
Extended by:
Helper::ZealotHelper
Defined in:
lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb

Constant Summary collapse

PLATFORM =
%I[ios mac macos osx android].freeze

Constants included from Helper::ZealotHelper

Helper::ZealotHelper::UPLOAD_APP_PARAMS_KEYS

Documentation collapse

Class Method Summary collapse

Methods included from Helper::ZealotHelper

avialable_upload_app_params, build_app_version_check_params, build_table_data, check_app_version, detect_ci_url, detect_source, gitlab?, hidden_keys, http_request, jenkins?, make_connection, print_table, show_error, sync_deivce, upload_app, upload_app_params, upload_debug_file, upload_debug_file_params

Class Method Details

.authorsObject



198
199
200
# File 'lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb', line 198

def self.authors
  ['icyleaf']
end

.available_optionsObject



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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb', line 82

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :endpoint,
                                 env_name: 'ZEALOT_ENDPOINT',
                                 description: 'The endpoint of zealot',
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :token,
                                 env_name: 'ZEALOT_TOKEN',
                                 description: 'The token of user',
                                 sensitive: true,
                                 verify_block: proc do |value|
                                   UI.user_error!("No user token for Zealot given, pass using `token: 'token'`") if value.nil? || value.empty?
                                 end,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :channel_key,
                                 env_name: 'ZEALOT_CHANNEL_KEY',
                                 description: 'The key of app\'s channel',
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :platform,
                                 env_name: 'ZEALOT_PLATFORM',
                                 description: "The name of platfrom, avaiable value are #{PLATFORM.join(',')}",
                                 verify_block: proc do |value|
                                   UI.user_error!("No match value of platform: #{value}") unless PLATFORM.include?(value)
                                 end,
                                 type: :Symbol),
    FastlaneCore::ConfigItem.new(key: :path,
                                 env_name: 'ZEALOT_PATH',
                                 description: 'The path of debug file (iOS/macOS is archive path for Xcode, Android is path for app project)',
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :xcode_scheme,
                                 env_name: 'ZEALOT_XCODE_SCHEME',
                                 description: 'The scheme name of app',
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :android_build_type,
                                 env_name: 'ZEALOT_ANDROID_BUILD_TYPE',
                                 description: 'The build type of app',
                                 default_value: Fastlane::Actions::ProguardAction::RELEASE_TYPE,
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :android_flavor,
                                 env_name: 'ZEALOT_ANDROID_FLAVOR',
                                 description: 'The product flavor of app',
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :extra_files,
                                 env_name: 'ZEALOT_EXTRA_FILES',
                                 description: 'A set file names',
                                 optional: true,
                                 default_value: [],
                                 type: Array),
    FastlaneCore::ConfigItem.new(key: :output_path,
                                 env_name: 'DF_DSYM_OUTPUT_PATH',
                                 description: "The output path of compressed dSYM file",
                                 default_value: '.',
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :release_version,
                                 env_name: 'ZEALOT_RELEASE_VERSION',
                                 description: 'The release version of app',
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :build_version,
                                 env_name: 'ZEALOT_BUILD_VERSION',
                                 description: 'The build version of app',
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :overwrite,
                                 env_name: 'DF_DSYM_OVERWRITE',
                                 description: "Overwrite output compressed file if it existed",
                                 default_value: false,
                                 type: Boolean),
    FastlaneCore::ConfigItem.new(key: :timeout,
                                 env_name: 'ZEALOT_TIMEOUT',
                                 description: 'Request timeout in seconds',
                                 type: Integer,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :verify_ssl,
                                 env_name: 'ZEALOT_VERIFY_SSL',
                                 description: 'Should verify SSL of zealot service',
                                 optional: true,
                                 default_value: true,
                                 type: Boolean),
    FastlaneCore::ConfigItem.new(key: :fail_on_error,
                                 env_name: 'ZEALOT_FAIL_ON_ERROR',
                                 description: 'Should an error uploading app cause a failure? (true/false)',
                                 optional: true,
                                 default_value: false,
                                 type: Boolean)
  ]
end

.categoryObject



194
195
196
# File 'lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb', line 194

def self.category
  :misc
end

.descriptionObject



78
79
80
# File 'lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb', line 78

def self.description
  'Upload a new build to Zealot'
end

.example_codeObject



175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb', line 175

def self.example_code
  [
    'zealot_debug_file(
      endpoint: "...",
      token: "...",
      channel_key: "...",
      zip_file: "...",
      release_version: "...",
      build_version: "..."
    )'
  ]
end

.generate_dsym_zip(params, path) ⇒ Object



43
44
45
46
47
48
49
50
51
52
# File 'lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb', line 43

def self.generate_dsym_zip(params, path)
  params[:archive_path] = if path
    path
  else
    Actions.lane_context[SharedValues::XCODEBUILD_ARCHIVE] || Fastlane::Actions::DsymAction::ARCHIVE_PATH
  end

  params[:scheme] = params.delete(:xcode_scheme)
  Fastlane::Actions::DsymAction.run(params)
end

.generate_proguard_zip(params, path) ⇒ Object



54
55
56
57
58
59
# File 'lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb', line 54

def self.generate_proguard_zip(params, path)
  params[:app_path] = path if path && !path.empty?
  params[:build_type] = params.delete(:android_build_type)
  params[:flavor] = params.delete(:android_flavor)
  Fastlane::Actions::ProguardAction.run(params)
end

.generate_zip_file(params) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb', line 25

def self.generate_zip_file(params)
  new_params = params.all_keys.each_with_object({}) do |key, obj|
    next unless value = params[key]
    obj[key] = value
  end
  path = new_params.delete(:path)
  platform = new_params[:platform]

  case platform
  when :ios, :mac, :macos, :osx
    generate_dsym_zip(new_params, path)
  when :android
    generate_proguard_zip(new_params, path)
  else
    UI.user_error!("No match value of platform: #{value}, avaiable value are #{PLATFORM.join(',')}.")
  end
end

.is_supported?(_) ⇒ Boolean

Returns:

  • (Boolean)


202
203
204
# File 'lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb', line 202

def self.is_supported?(_)
  true
end

.outputObject



188
189
190
191
192
# File 'lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb', line 188

def self.output
  [
    ['ZEAALOT_ERROR_MESSAGE', 'The error message during upload process']
  ]
end

.run(params) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/fastlane/plugin/zealot/actions/zealot_debug_file.rb', line 15

def self.run(params)
  file = generate_zip_file(params)
  UI.user_error! "Something wrong with compress debug file" unless file

  response = upload_debug_file(params, file)
  if parse_response(response, params[:endpoint], params[:fail_on_error])
    UI.success('Build successfully uploaded to Zealot.')
  end
end