Class: Fastlane::Actions::HockeyAction
- Inherits:
-
Fastlane::Action
- Object
- Fastlane::Action
- Fastlane::Actions::HockeyAction
- Defined in:
- fastlane/lib/fastlane/actions/hockey.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary
Constants inherited from Fastlane::Action
Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES
Class Method Summary collapse
- .author ⇒ Object
- .available_options ⇒ Object
- .category ⇒ Object
- .connection(options) ⇒ Object
-
.create_and_update_build(api_token, ipa, options) ⇒ Object
Uses support.hockeyapp.net/kb/api/api-versions#create-version and support.hockeyapp.net/kb/api/api-versions#update-version to upload a build.
- .description ⇒ Object
- .details ⇒ Object
- .example_code ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .output ⇒ Object
- .run(options) ⇒ Object
- .upload(api_token, ipa, options) ⇒ Object
-
.upload_build(api_token, ipa, options) ⇒ Object
Uses support.hockeyapp.net/kb/api/api-versions#upload-version if a ‘public_identifier` was specified otherwise support.hockeyapp.net/kb/api/api-apps#upload-app.
Methods inherited from Fastlane::Action
action_name, authors, deprecated_notes, lane_context, method_missing, other_action, return_type, return_value, sample_return_value, shell_out_should_use_bundle_exec?, step_text
Class Method Details
.author ⇒ Object
349 350 351 |
# File 'fastlane/lib/fastlane/actions/hockey.rb', line 349 def self. ["KrauseFx", "modzelewski", "lacostej"] end |
.available_options ⇒ Object
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
# File 'fastlane/lib/fastlane/actions/hockey.rb', line 189 def self. [ FastlaneCore::ConfigItem.new(key: :apk, env_name: "FL_HOCKEY_APK", description: "Path to your APK file", default_value: Actions.lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH], default_value_dynamic: true, optional: true, verify_block: proc do |value| UI.user_error!("Couldn't find apk file at path '#{value}'") unless File.exist?(value) end, conflicting_options: [:ipa], conflict_block: proc do |value| UI.user_error!("You can't use 'apk' and '#{value.key}' options in one run") end), FastlaneCore::ConfigItem.new(key: :api_token, env_name: "FL_HOCKEY_API_TOKEN", sensitive: true, description: "API Token for Hockey Access", verify_block: proc do |value| UI.user_error!("No API token for Hockey given, pass using `api_token: 'token'`") unless value && !value.empty? end), FastlaneCore::ConfigItem.new(key: :ipa, env_name: "FL_HOCKEY_IPA", description: "Path to your IPA file. Optional if you use the _gym_ or _xcodebuild_ action. For Mac zip the .app. For Android provide path to .apk file. In addition you could use this to upload .msi, .zip, .pkg, etc if you use the 'create_update' mechanism", default_value: Actions.lane_context[SharedValues::IPA_OUTPUT_PATH], default_value_dynamic: true, optional: true, verify_block: proc do |value| UI.user_error!("Couldn't find ipa file at path '#{value}'") unless File.exist?(value) end, conflicting_options: [:apk], conflict_block: proc do |value| UI.user_error!("You can't use 'ipa' and '#{value.key}' options in one run") end), FastlaneCore::ConfigItem.new(key: :dsym, env_name: "FL_HOCKEY_DSYM", description: "Path to your symbols file. For iOS and Mac provide path to app.dSYM.zip. For Android provide path to mappings.txt file", default_value: Actions.lane_context[SharedValues::DSYM_OUTPUT_PATH], default_value_dynamic: true, optional: true, verify_block: proc do |value| # validation is done in the action end), FastlaneCore::ConfigItem.new(key: :create_update, env_name: "FL_HOCKEY_CREATE_UPDATE", description: "Set true if you want to create then update your app as opposed to just upload it."\ " You will need the 'public_identifier', 'bundle_version' and 'bundle_short_version'", is_string: false, default_value: false, verify_block: proc do |value| # validation is done in the action end), FastlaneCore::ConfigItem.new(key: :notes, env_name: "FL_HOCKEY_NOTES", description: "Beta Notes", default_value: Actions.lane_context[SharedValues::FL_CHANGELOG] || "No changelog given", default_value_dynamic: true), FastlaneCore::ConfigItem.new(key: :notify, env_name: "FL_HOCKEY_NOTIFY", description: "Notify testers? \"1\" for yes", default_value: "1"), FastlaneCore::ConfigItem.new(key: :status, env_name: "FL_HOCKEY_STATUS", description: "Download status: \"1\" = No user can download; \"2\" = Available for download (only possible with full-access token)", default_value: "2"), FastlaneCore::ConfigItem.new(key: :create_status, env_name: "FL_HOCKEY_CREATE_STATUS", description: "Download status for initial version creation when create_update is true: \"1\" = No user can download; \"2\" = Available for download (only possible with full-access token)", default_value: "2"), FastlaneCore::ConfigItem.new(key: :notes_type, env_name: "FL_HOCKEY_NOTES_TYPE", description: "Notes type for your :notes, \"0\" = Textile, \"1\" = Markdown (default)", default_value: "1"), FastlaneCore::ConfigItem.new(key: :release_type, env_name: "FL_HOCKEY_RELEASE_TYPE", description: "Release type of the app: \"0\" = Beta (default), \"1\" = Store, \"2\" = Alpha, \"3\" = Enterprise", default_value: "0"), FastlaneCore::ConfigItem.new(key: :mandatory, env_name: "FL_HOCKEY_MANDATORY", description: "Set to \"1\" to make this update mandatory", default_value: "0"), FastlaneCore::ConfigItem.new(key: :teams, env_name: "FL_HOCKEY_TEAMS", description: "Comma separated list of team ID numbers to which this build will be restricted", optional: true), FastlaneCore::ConfigItem.new(key: :users, env_name: "FL_HOCKEY_USERS", description: "Comma separated list of user ID numbers to which this build will be restricted", optional: true), FastlaneCore::ConfigItem.new(key: :tags, env_name: "FL_HOCKEY_TAGS", description: "Comma separated list of tags which will receive access to the build", optional: true), FastlaneCore::ConfigItem.new(key: :bundle_short_version, env_name: "FL_HOCKEY_BUNDLE_SHORT_VERSION", description: "The bundle_short_version of your application, required when using `create_update`", optional: true), FastlaneCore::ConfigItem.new(key: :bundle_version, env_name: "FL_HOCKEY_BUNDLE_VERSION", description: "The bundle_version of your application, required when using `create_update`", optional: true), FastlaneCore::ConfigItem.new(key: :public_identifier, env_name: "FL_HOCKEY_PUBLIC_IDENTIFIER", description: "App id of the app you are targeting, usually you won't need this value. Required, if `upload_dsym_only` set to `true`", optional: true), FastlaneCore::ConfigItem.new(key: :commit_sha, env_name: "FL_HOCKEY_COMMIT_SHA", description: "The Git commit SHA for this build", optional: true), FastlaneCore::ConfigItem.new(key: :repository_url, env_name: "FL_HOCKEY_REPOSITORY_URL", description: "The URL of your source repository", optional: true), FastlaneCore::ConfigItem.new(key: :build_server_url, env_name: "FL_HOCKEY_BUILD_SERVER_URL", description: "The URL of the build job on your build server", optional: true), FastlaneCore::ConfigItem.new(key: :upload_dsym_only, env_name: "FL_HOCKEY_UPLOAD_DSYM_ONLY", description: "Flag to upload only the dSYM file to hockey app", is_string: false, default_value: false), FastlaneCore::ConfigItem.new(key: :owner_id, env_name: "FL_HOCKEY_OWNER_ID", description: "ID for the owner of the app", optional: true), FastlaneCore::ConfigItem.new(key: :strategy, env_name: "FL_HOCKEY_STRATEGY", description: "Strategy: 'add' = to add the build as a new build even if it has the same build number (default); 'replace' = to replace a build with the same build number", default_value: "add", verify_block: proc do |value| UI.user_error!("Invalid value '#{value}' for key 'strategy'. Allowed values are 'add', 'replace'.") unless ['add', 'replace'].include?(value) end), FastlaneCore::ConfigItem.new(key: :timeout, env_name: "FL_HOCKEY_TIMEOUT", description: "Request timeout in seconds", type: Integer, optional: true), FastlaneCore::ConfigItem.new(key: :bypass_cdn, env_name: "FL_HOCKEY_BYPASS_CDN", description: "Flag to bypass Hockey CDN when it uploads successfully but reports error", is_string: false, default_value: false), FastlaneCore::ConfigItem.new(key: :dsa_signature, env_name: "FL_HOCKEY_DSA_SIGNATURE", description: "DSA signature for sparkle updates for macOS", is_string: true, default_value: "", optional: true) ] end |
.category ⇒ Object
383 384 385 |
# File 'fastlane/lib/fastlane/actions/hockey.rb', line 383 def self.category :beta end |
.connection(options) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'fastlane/lib/fastlane/actions/hockey.rb', line 10 def self.connection() require 'faraday' require 'faraday_middleware' base_url = .delete(:bypass_cdn) ? "https://rink.hockeyapp.net" : "https://upload.hockeyapp.net" = { url: base_url } Faraday.new() do |builder| builder.request(:multipart) builder.request(:url_encoded) builder.response(:json, content_type: /\bjson$/) builder.use(FaradayMiddleware::FollowRedirects) builder.adapter(:net_http) end end |
.create_and_update_build(api_token, ipa, options) ⇒ Object
Uses support.hockeyapp.net/kb/api/api-versions#create-version and support.hockeyapp.net/kb/api/api-versions#update-version to upload a build
64 65 66 67 68 69 70 71 72 73 74 75 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 114 115 116 117 118 |
# File 'fastlane/lib/fastlane/actions/hockey.rb', line 64 def self.create_and_update_build(api_token, ipa, ) [:public_identifier, :bundle_short_version, :bundle_version].each do |key| UI.user_error!("To use the 'create_update' upload mechanism you need to pass the '#{key.to_sym}' option.") unless [key] end # https://support.hockeyapp.net/discussions/problems/33355-is-uploadhockeyappnet-available-for-general-use # GET requests are cached on CDN, so bypass it [:bypass_cdn] = true connection = self.connection() .delete(:ipa) .delete(:apk) app_id = .delete(:public_identifier) ipaio = Faraday::UploadIO.new(ipa, 'application/octet-stream') if ipa && File.exist?(ipa) dsym = .delete(:dsym) if dsym dsym_io = Faraday::UploadIO.new(dsym, 'application/octet-stream') if dsym && File.exist?(dsym) end # https://support.hockeyapp.net/discussions/problems/83559 # Should not set status to "2" (downloadable) until after the app is uploaded, so allow the caller # to specify a different status for the `create` step update_status = [:status] [:status] = [:create_status] response = connection.get do |req| req.url("/api/2/apps/#{app_id}/app_versions/new") req.headers['X-HockeyAppToken'] = api_token req.body = end case response.status when 200...300 app_version_id = response.body['id'] UI.("successfully created version with id #{app_version_id}") else UI.user_error!("Error trying to create app version: #{response.status} - #{response.body}") end [:ipa] = ipaio if dsym [:dsym] = dsym_io end [:status] = update_status connection.put do |req| req..timeout = .delete(:timeout) req.url("/api/2/apps/#{app_id}/app_versions/#{app_version_id}") req.headers['X-HockeyAppToken'] = api_token req.body = end end |
.description ⇒ Object
185 186 187 |
# File 'fastlane/lib/fastlane/actions/hockey.rb', line 185 def self.description "Upload a new build to [HockeyApp](https://hockeyapp.net/)" end |
.details ⇒ Object
357 358 359 360 361 362 |
# File 'fastlane/lib/fastlane/actions/hockey.rb', line 357 def self.details [ "Symbols will also be uploaded automatically if a `app.dSYM.zip` file is found next to `app.ipa`. In case it is located in a different place you can specify the path explicitly in the `:dsym` parameter.", "More information about the available options can be found in the [HockeyApp Docs](http://support.hockeyapp.net/kb/api/api-versions#upload-version)." ].join("\n") end |
.example_code ⇒ Object
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 |
# File 'fastlane/lib/fastlane/actions/hockey.rb', line 364 def self.example_code [ 'hockey( api_token: "...", ipa: "./app.ipa", notes: "Changelog" )', 'hockey( api_token: "...", create_update: true, public_identifier: "....", bundle_short_version: "1.0.2", bundle_version: "1.0.2.145", ipa: "./my.msi", notes: "Changelog" )' ] end |
.is_supported?(platform) ⇒ Boolean
353 354 355 |
# File 'fastlane/lib/fastlane/actions/hockey.rb', line 353 def self.is_supported?(platform) true end |
.output ⇒ Object
342 343 344 345 346 347 |
# File 'fastlane/lib/fastlane/actions/hockey.rb', line 342 def self.output [ ['HOCKEY_DOWNLOAD_LINK', 'The newly generated download link for this build'], ['HOCKEY_BUILD_INFORMATION', 'contains all keys/values from the HockeyApp API, like :title, :bundle_identifier'] ] end |
.run(options) ⇒ Object
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 174 175 176 177 178 179 180 181 182 183 |
# File 'fastlane/lib/fastlane/actions/hockey.rb', line 120 def self.run() build_file = [ [:ipa], [:apk] ].detect { |e| !e.to_s.empty? } if [:dsym] dsym_filename = [:dsym] else if build_file.nil? UI.user_error!("You have to provide a build file (params 'apk' or 'ipa')") end if [:ipa].to_s.end_with?(".ipa") dsym_path = [:ipa].to_s.gsub('.ipa', '.app.dSYM.zip') if File.exist?(dsym_path) dsym_filename = dsym_path else UI.important("Symbols not found on path #{File.(dsym_path)}. Crashes won't be symbolicated properly") dsym_filename = nil end end end UI.user_error!("Symbols on path '#{File.(dsym_filename)}' not found") if dsym_filename && !File.exist?(dsym_filename) if [:upload_dsym_only] UI.success('Starting with dSYM upload to HockeyApp... this could take some time.') else UI.success('Starting with file(s) upload to HockeyApp... this could take some time.') end values = .values values[:dsym_filename] = dsym_filename values[:notes_type] = [:notes_type] api_token = values.delete(:api_token) values.delete_if { |k, v| v.nil? } return values if Helper.test? ipa_filename = build_file ipa_filename = nil if [:upload_dsym_only] response = self.upload(api_token, ipa_filename, values) case response.status when 200...300 url = response.body['public_url'] Actions.lane_context[SharedValues::HOCKEY_DOWNLOAD_LINK] = url Actions.lane_context[SharedValues::HOCKEY_BUILD_INFORMATION] = response.body UI.("Public Download URL: #{url}") if url UI.success('Build successfully uploaded to HockeyApp!') else if response.body.to_s.include?("App could not be created") UI.user_error!("Hockey has an issue processing this app. Please confirm that an app in Hockey matches this IPA's bundle ID or that you are using the correct API upload token. If error persists, please provide the :public_identifier option from the HockeyApp website. More information https://github.com/fastlane/fastlane/issues/400") else UI.user_error!("Error when trying to upload file(s) to HockeyApp: #{response.status} - #{response.body}") end end end |
.upload(api_token, ipa, options) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'fastlane/lib/fastlane/actions/hockey.rb', line 27 def self.upload(api_token, ipa, ) create_update = .delete(:create_update) if create_update self.create_and_update_build(api_token, ipa, ) else self.upload_build(api_token, ipa, ) end end |
.upload_build(api_token, ipa, options) ⇒ Object
Uses support.hockeyapp.net/kb/api/api-versions#upload-version if a ‘public_identifier` was specified otherwise support.hockeyapp.net/kb/api/api-apps#upload-app
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'fastlane/lib/fastlane/actions/hockey.rb', line 39 def self.upload_build(api_token, ipa, ) connection = self.connection() [:ipa] = Faraday::UploadIO.new(ipa, 'application/octet-stream') if ipa && File.exist?(ipa) dsym_filename = .delete(:dsym_filename) if dsym_filename [:dsym] = Faraday::UploadIO.new(dsym_filename, 'application/octet-stream') end connection.post do |req| req..timeout = .delete(:timeout) if [:public_identifier].nil? req.url("/api/2/apps/upload") else req.url("/api/2/apps/#{.delete(:public_identifier)}/app_versions/upload") end req.headers['X-HockeyAppToken'] = api_token req.body = end end |