fastlane-plugin-appcenter 1.11.0 → 1.11.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c1262b958ae0ddbf9a6bfa6d63b4f032f1518c706154e6c70b35adbe2c441e2
4
- data.tar.gz: c2ffa81d7a6e4c8fb369c5d4612a0aea7c02c2cd589a3fdcb900d8b407f2eaae
3
+ metadata.gz: b110405fe9e84494ddb201d8b05738652c29493a2d86cf33a83f63e3843c650f
4
+ data.tar.gz: a6a582ac374e02c45a5285b6960d8f0da7a44bb7f4375c2d001d25a3aad71d21
5
5
  SHA512:
6
- metadata.gz: eb06867a95f13d484796bd47be5cad11df03e949ffffbcbf8cbe14d675c8577506e184176248ba8102fc338ab934e9d03e06938030591d9d9a72beec557f7894
7
- data.tar.gz: b1fadb157505f3138621dffd8e95a64d306f89439ab25259c60c6a9e08d9a9dbe97d0b09b4c1daf8db70e2c9241d87225523784cb3f9c5e900c98d3a85b0b05f
6
+ metadata.gz: 6e30d4329779b399e127a8f31b2828ce307c586ea06539970d3b1ed338db5a1c4222364f269aab763fdb97b18abfc73de67ea0f1928397a3b8dc4b300998afd4
7
+ data.tar.gz: 766537e348299e02cd0e71f21502884487e76e333941e291229167e4554193d0284faff27eae2f91da24fc9b6a39425bc999e489001cefbd8582485c3f996b78
@@ -67,14 +67,23 @@ module Fastlane
67
67
 
68
68
  UI.message("DEBUG: POST #{url}") if ENV['DEBUG']
69
69
  UI.message("DEBUG: POST body: #{JSON.pretty_generate(body)}\n") if ENV['DEBUG']
70
- response = connection.post(url) do |req|
71
- req.headers['X-API-Token'] = api_token
72
- req.headers['internal-request-source'] = "fastlane"
73
- req.body = body
70
+
71
+ status, message, response = retry_429_and_error do
72
+ response = connection.post(url) do |req|
73
+ req.headers['X-API-Token'] = api_token
74
+ req.headers['internal-request-source'] = "fastlane"
75
+ req.body = body
76
+ end
74
77
  end
75
78
 
76
- UI.message("DEBUG: #{response.status} #{JSON.pretty_generate(response.body)}\n") if ENV['DEBUG']
77
- case response.status
79
+ case status
80
+ when 0, 429
81
+ if status == 0
82
+ UI.error("Faraday http exception creating release upload: #{message}")
83
+ else
84
+ UI.error("Retryable error creating release upload #{status}: #{message}")
85
+ end
86
+ false
78
87
  when 200...300
79
88
  response.body
80
89
  when 401
@@ -110,15 +119,22 @@ module Fastlane
110
119
  UI.message("DEBUG: POST #{url}") if ENV['DEBUG']
111
120
  UI.message("DEBUG: POST body #{JSON.pretty_generate(body)}\n") if ENV['DEBUG']
112
121
 
113
- response = connection.post(url) do |req|
114
- req.headers['X-API-Token'] = api_token
115
- req.headers['internal-request-source'] = "fastlane"
116
- req.body = body
122
+ status, message, response = retry_429_and_error do
123
+ response = connection.post(url) do |req|
124
+ req.headers['X-API-Token'] = api_token
125
+ req.headers['internal-request-source'] = "fastlane"
126
+ req.body = body
127
+ end
117
128
  end
118
129
 
119
- UI.message("DEBUG: #{response.status} #{JSON.pretty_generate(response.body)}\n") if ENV['DEBUG']
120
-
121
- case response.status
130
+ case status
131
+ when 0, 429
132
+ if status == 0
133
+ UI.error("Faraday http exception creating mapping upload: #{message}")
134
+ else
135
+ UI.error("Retryable error creating mapping upload #{status}: #{message}")
136
+ end
137
+ false
122
138
  when 200...300
123
139
  response.body
124
140
  when 401
@@ -149,15 +165,22 @@ module Fastlane
149
165
  UI.message("DEBUG: POST #{url}") if ENV['DEBUG']
150
166
  UI.message("DEBUG: POST body #{JSON.pretty_generate(body)}\n") if ENV['DEBUG']
151
167
 
152
- response = connection.post(url) do |req|
153
- req.headers['X-API-Token'] = api_token
154
- req.headers['internal-request-source'] = "fastlane"
155
- req.body = body
168
+ status, message, response = retry_429_and_error do
169
+ response = connection.post(url) do |req|
170
+ req.headers['X-API-Token'] = api_token
171
+ req.headers['internal-request-source'] = "fastlane"
172
+ req.body = body
173
+ end
156
174
  end
157
175
 
158
- UI.message("DEBUG: #{response.status} #{JSON.pretty_generate(response.body)}\n") if ENV['DEBUG']
159
-
160
- case response.status
176
+ case status
177
+ when 0, 429
178
+ if status == 0
179
+ UI.error("Faraday http exception creating dsym upload: #{message}")
180
+ else
181
+ UI.error("Retryable error creating dsym upload #{status}: #{message}")
182
+ end
183
+ false
161
184
  when 200...300
162
185
  response.body
163
186
  when 401
@@ -184,15 +207,22 @@ module Fastlane
184
207
  UI.message("DEBUG: PATCH #{url}") if ENV['DEBUG']
185
208
  UI.message("DEBUG: PATCH body #{JSON.pretty_generate(body)}\n") if ENV['DEBUG']
186
209
 
187
- response = connection.patch(url) do |req|
188
- req.headers['X-API-Token'] = api_token
189
- req.headers['internal-request-source'] = "fastlane"
190
- req.body = body
210
+ status, message, response = retry_429_and_error do
211
+ response = connection.patch(url) do |req|
212
+ req.headers['X-API-Token'] = api_token
213
+ req.headers['internal-request-source'] = "fastlane"
214
+ req.body = body
215
+ end
191
216
  end
192
-
193
- UI.message("DEBUG: #{response.status} #{JSON.pretty_generate(response.body)}\n") if ENV['DEBUG']
194
-
195
- case response.status
217
+
218
+ case status
219
+ when 0, 429
220
+ if status == 0
221
+ UI.error("Faraday http exception updating symbol upload: #{message}")
222
+ else
223
+ UI.error("Retryable error updating symbol upload #{status}: #{message}")
224
+ end
225
+ false
196
226
  when 200...300
197
227
  response.body
198
228
  when 401
@@ -213,19 +243,26 @@ module Fastlane
213
243
  UI.message("DEBUG: PUT #{upload_url}") if ENV['DEBUG']
214
244
  UI.message("DEBUG: PUT body <data>\n") if ENV['DEBUG']
215
245
 
216
- response = connection.put do |req|
217
- req.headers['x-ms-blob-type'] = "BlockBlob"
218
- req.headers['Content-Length'] = File.size(symbol).to_s
219
- req.headers['internal-request-source'] = "fastlane"
220
- req.body = Faraday::UploadIO.new(symbol, 'application/octet-stream') if symbol && File.exist?(symbol)
221
- end
222
-
223
- UI.message("DEBUG: #{response.status} #{JSON.pretty_generate(response.body)}\n") if ENV['DEBUG']
224
-
225
246
  log_type = "dSYM" if symbol_type == "Apple"
226
247
  log_type = "mapping" if symbol_type == "Android"
227
248
 
228
- case response.status
249
+ status, message, response = retry_429_and_error do
250
+ response = connection.put do |req|
251
+ req.headers['x-ms-blob-type'] = "BlockBlob"
252
+ req.headers['Content-Length'] = File.size(symbol).to_s
253
+ req.headers['internal-request-source'] = "fastlane"
254
+ req.body = Faraday::UploadIO.new(symbol, 'application/octet-stream') if symbol && File.exist?(symbol)
255
+ end
256
+ end
257
+
258
+ case status
259
+ when 0, 429
260
+ if status == 0
261
+ UI.error("Faraday http exception updating symbol upload: #{message}")
262
+ else
263
+ UI.error("Retryable error updating symbol upload #{status}: #{message}")
264
+ end
265
+ false
229
266
  when 200...300
230
267
  self.update_symbol_upload(api_token, owner_name, app_name, symbol_upload_id, 'committed')
231
268
  UI.success("#{log_type} uploaded")
@@ -248,13 +285,22 @@ module Fastlane
248
285
 
249
286
  UI.message("DEBUG: POST #{set_metadata_url}") if ENV['DEBUG']
250
287
  UI.message("DEBUG: POST body <data>\n") if ENV['DEBUG']
251
- response = connection.post do |req|
252
- req.options.timeout = timeout
253
- req.headers['internal-request-source'] = "fastlane"
288
+
289
+ status, message, response = retry_429_and_error do
290
+ response = connection.post do |req|
291
+ req.options.timeout = timeout
292
+ req.headers['internal-request-source'] = "fastlane"
293
+ end
254
294
  end
255
- UI.message("DEBUG: #{response.status} #{JSON.pretty_generate(response.body)}\n") if ENV['DEBUG']
256
295
 
257
- case response.status
296
+ case status
297
+ when 0, 429
298
+ if status == 0
299
+ UI.error("Faraday http exception releasing upload metadata: #{message}")
300
+ else
301
+ UI.error("Retryable error releasing upload metadata #{status}: #{message}")
302
+ end
303
+ false
258
304
  when 200...300
259
305
  chunk_size = response.body['chunk_size']
260
306
  unless chunk_size.is_a? Integer
@@ -280,13 +326,22 @@ module Fastlane
280
326
  connection = self.connection(finish_url)
281
327
 
282
328
  UI.message("DEBUG: POST #{finish_url}") if ENV['DEBUG']
283
- response = connection.post do |req|
284
- req.options.timeout = timeout
285
- req.headers['internal-request-source'] = "fastlane"
329
+
330
+ status, message, response = retry_429_and_error do
331
+ response = connection.post do |req|
332
+ req.options.timeout = timeout
333
+ req.headers['internal-request-source'] = "fastlane"
334
+ end
286
335
  end
287
- UI.message("DEBUG: #{response.status} #{JSON.pretty_generate(response.body)}\n") if ENV['DEBUG']
288
336
 
289
- case response.status
337
+ case status
338
+ when 0, 429
339
+ if status == 0
340
+ UI.error("Faraday http exception finishing release upload: #{message}")
341
+ else
342
+ UI.error("Retryable error finishing release upload #{status}: #{message}")
343
+ end
344
+ false
290
345
  when 200...300
291
346
  if response.body['error'] == false
292
347
  UI.message("Upload finished")
@@ -381,15 +436,22 @@ module Fastlane
381
436
  UI.message("DEBUG: PATCH #{url}") if ENV['DEBUG']
382
437
  UI.message("DEBUG: PATCH body #{JSON.pretty_generate(body)}\n") if ENV['DEBUG']
383
438
 
384
- response = connection.patch(url) do |req|
385
- req.headers['X-API-Token'] = api_token
386
- req.headers['internal-request-source'] = "fastlane"
387
- req.body = body
439
+ status, message, response = retry_429_and_error do
440
+ response = connection.patch(url) do |req|
441
+ req.headers['X-API-Token'] = api_token
442
+ req.headers['internal-request-source'] = "fastlane"
443
+ req.body = body
444
+ end
388
445
  end
389
446
 
390
- UI.message("DEBUG: #{response.status} #{JSON.pretty_generate(response.body)}\n") if ENV['DEBUG']
391
-
392
- case response.status
447
+ case status
448
+ when 0, 429
449
+ if status == 0
450
+ UI.error("Faraday http exception updating release upload: #{message}")
451
+ else
452
+ UI.error("Retryable error updating release upload #{status}: #{message}")
453
+ end
454
+ false
393
455
  when 200...300
394
456
  response.body
395
457
  when 401
@@ -411,14 +473,21 @@ module Fastlane
411
473
 
412
474
  UI.message("DEBUG: GET #{url}") if ENV['DEBUG']
413
475
 
414
- response = connection.get(url) do |req|
415
- req.headers['X-API-Token'] = api_token
416
- req.headers['internal-request-source'] = "fastlane"
476
+ status, message, response = retry_429_and_error do
477
+ response = connection.get(url) do |req|
478
+ req.headers['X-API-Token'] = api_token
479
+ req.headers['internal-request-source'] = "fastlane"
480
+ end
417
481
  end
418
482
 
419
- UI.message("DEBUG: #{response.status} #{JSON.pretty_generate(response.body)}\n") if ENV['DEBUG']
420
-
421
- case response.status
483
+ case status
484
+ when 0, 429
485
+ if status == 0
486
+ UI.error("Faraday http exception getting release: #{message}")
487
+ else
488
+ UI.error("Retryable error getting release: #{status}: #{message}")
489
+ end
490
+ false
422
491
  when 200...300
423
492
  release = response.body
424
493
  release
@@ -443,14 +512,22 @@ module Fastlane
443
512
 
444
513
  while true
445
514
  UI.message("DEBUG: GET #{url}") if ENV['DEBUG']
446
- response = connection.get(url) do |req|
447
- req.headers['X-API-Token'] = api_token
448
- req.headers['internal-request-source'] = "fastlane"
449
- end
450
515
 
451
- UI.message("DEBUG: #{response.status} #{JSON.pretty_generate(response.body)}\n") if ENV['DEBUG']
516
+ status, message, response = retry_429_and_error do
517
+ response = connection.get(url) do |req|
518
+ req.headers['X-API-Token'] = api_token
519
+ req.headers['internal-request-source'] = "fastlane"
520
+ end
521
+ end
452
522
 
453
- case response.status
523
+ case status
524
+ when 0, 429
525
+ if status == 0
526
+ UI.error("Faraday http exception polling for release id: #{message}")
527
+ else
528
+ UI.error("Retryable error polling for release id: #{status}: #{message}")
529
+ end
530
+ return false
454
531
  when 200...300
455
532
  case response.body['upload_status']
456
533
  when "readyToBePublished"
@@ -476,14 +553,21 @@ module Fastlane
476
553
 
477
554
  UI.message("DEBUG: GET #{url}") if ENV['DEBUG']
478
555
 
479
- response = connection.get(url) do |req|
480
- req.headers['X-API-Token'] = api_token
481
- req.headers['internal-request-source'] = "fastlane"
556
+ status, message, response = retry_429_and_error do
557
+ response = connection.get(url) do |req|
558
+ req.headers['X-API-Token'] = api_token
559
+ req.headers['internal-request-source'] = "fastlane"
560
+ end
482
561
  end
483
562
 
484
- UI.message("DEBUG: #{response.status} #{JSON.pretty_generate(response.body)}\n") if ENV['DEBUG']
485
-
486
- case response.status
563
+ case status
564
+ when 0, 429
565
+ if status == 0
566
+ UI.error("Faraday http exception getting destination: #{message}")
567
+ else
568
+ UI.error("Retryable error getting destination: #{status}: #{message}")
569
+ end
570
+ false
487
571
  when 200...300
488
572
  destination = response.body
489
573
  destination
@@ -511,15 +595,22 @@ module Fastlane
511
595
  UI.message("DEBUG: PUT #{url}") if ENV['DEBUG']
512
596
  UI.message("DEBUG: PUT body #{JSON.pretty_generate(body)}\n") if ENV['DEBUG']
513
597
 
514
- response = connection.put(url) do |req|
515
- req.headers['X-API-Token'] = api_token
516
- req.headers['internal-request-source'] = "fastlane"
517
- req.body = body
598
+ status, message, response = retry_429_and_error do
599
+ response = connection.put(url) do |req|
600
+ req.headers['X-API-Token'] = api_token
601
+ req.headers['internal-request-source'] = "fastlane"
602
+ req.body = body
603
+ end
518
604
  end
519
605
 
520
- UI.message("DEBUG: #{response.status} #{JSON.pretty_generate(response.body)}\n") if ENV['DEBUG']
521
-
522
- case response.status
606
+ case status
607
+ when 0, 429
608
+ if status == 0
609
+ UI.error("Faraday http exception updating release: #{message}")
610
+ else
611
+ UI.error("Retryable error updating release: #{status}: #{message}")
612
+ end
613
+ false
523
614
  when 200...300
524
615
  # get full release info
525
616
  release = self.get_release(api_token, owner_name, app_name, release_id)
@@ -565,15 +656,23 @@ module Fastlane
565
656
  UI.message("DEBUG: PATCH body #{JSON.pretty_generate(body)}\n") if ENV['DEBUG']
566
657
 
567
658
  connection = self.connection
568
- response = connection.patch(url) do |req|
569
- req.headers['X-API-Token'] = api_token
570
- req.headers['internal-request-source'] = "fastlane"
571
- req.body = body
572
- end
573
659
 
574
- UI.message("DEBUG: #{response.status} #{JSON.pretty_generate(response.body)}\n") if ENV['DEBUG']
660
+ status, message, response = retry_429_and_error do
661
+ response = connection.patch(url) do |req|
662
+ req.headers['X-API-Token'] = api_token
663
+ req.headers['internal-request-source'] = "fastlane"
664
+ req.body = body
665
+ end
666
+ end
575
667
 
576
- case response.status
668
+ case status
669
+ when 0, 429
670
+ if status == 0
671
+ UI.error("Faraday http exception updating release metadata: #{message}")
672
+ else
673
+ UI.error("Retryable error updating release metadata: #{status}: #{message}")
674
+ end
675
+ false
577
676
  when 200...300
578
677
  UI.message("Release Metadata was successfully updated for release '#{release_id}'")
579
678
  when 404
@@ -605,15 +704,22 @@ module Fastlane
605
704
  UI.message("DEBUG: POST #{url}") if ENV['DEBUG']
606
705
  UI.message("DEBUG: POST body #{JSON.pretty_generate(body)}\n") if ENV['DEBUG']
607
706
 
608
- response = connection.post(url) do |req|
609
- req.headers['X-API-Token'] = api_token
610
- req.headers['internal-request-source'] = "fastlane"
611
- req.body = body
707
+ status, message, response = retry_429_and_error do
708
+ response = connection.post(url) do |req|
709
+ req.headers['X-API-Token'] = api_token
710
+ req.headers['internal-request-source'] = "fastlane"
711
+ req.body = body
712
+ end
612
713
  end
613
714
 
614
- UI.message("DEBUG: #{response.status} #{JSON.pretty_generate(response.body)}\n") if ENV['DEBUG']
615
-
616
- case response.status
715
+ case status
716
+ when 0, 429
717
+ if status == 0
718
+ UI.error("Faraday http exception adding to destination: #{message}")
719
+ else
720
+ UI.error("Retryable error adding to destination: #{status}: #{message}")
721
+ end
722
+ false
617
723
  when 200...300
618
724
  # get full release info
619
725
  release = self.get_release(api_token, owner_name, app_name, release_id)
@@ -647,14 +753,21 @@ module Fastlane
647
753
 
648
754
  UI.message("DEBUG: GET #{url}") if ENV['DEBUG']
649
755
 
650
- response = connection.get(url) do |req|
651
- req.headers['X-API-Token'] = api_token
652
- req.headers['internal-request-source'] = "fastlane"
756
+ status, message, response = retry_429_and_error do
757
+ response = connection.get(url) do |req|
758
+ req.headers['X-API-Token'] = api_token
759
+ req.headers['internal-request-source'] = "fastlane"
760
+ end
653
761
  end
654
762
 
655
- UI.message("DEBUG: #{response.status} #{JSON.pretty_generate(response.body)}\n") if ENV['DEBUG']
656
-
657
- case response.status
763
+ case status
764
+ when 0, 429
765
+ if status == 0
766
+ UI.error("Faraday http exception getting app: #{message}")
767
+ else
768
+ UI.error("Retryable error getting app: #{status}: #{message}")
769
+ end
770
+ false
658
771
  when 200...300
659
772
  UI.message("DEBUG: #{JSON.pretty_generate(response.body)}\n") if ENV['DEBUG']
660
773
  true
@@ -685,15 +798,22 @@ module Fastlane
685
798
  UI.message("DEBUG: POST #{url}") if ENV['DEBUG']
686
799
  UI.message("DEBUG: POST body #{JSON.pretty_generate(body)}\n") if ENV['DEBUG']
687
800
 
688
- response = connection.post(url) do |req|
689
- req.headers['X-API-Token'] = api_token
690
- req.headers['internal-request-source'] = "fastlane"
691
- req.body = body
801
+ status, message, response = retry_429_and_error do
802
+ response = connection.post(url) do |req|
803
+ req.headers['X-API-Token'] = api_token
804
+ req.headers['internal-request-source'] = "fastlane"
805
+ req.body = body
806
+ end
692
807
  end
693
808
 
694
- UI.message("DEBUG: #{response.status} #{JSON.pretty_generate(response.body)}\n") if ENV['DEBUG']
695
-
696
- case response.status
809
+ case status
810
+ when 0, 429
811
+ if status == 0
812
+ UI.error("Faraday http exception creating app: #{message}")
813
+ else
814
+ UI.error("Retryable error creating app: #{status}: #{message}")
815
+ end
816
+ false
697
817
  when 200...300
698
818
  created = response.body
699
819
  UI.success("Created #{os}/#{platform} app with name \"#{created['name']}\" and display name \"#{created['display_name']}\" for #{owner_type} \"#{owner_name}\"")
@@ -714,14 +834,21 @@ module Fastlane
714
834
 
715
835
  UI.message("DEBUG: GET #{url}") if ENV['DEBUG']
716
836
 
717
- response = connection.get(url) do |req|
718
- req.headers['X-API-Token'] = api_token
719
- req.headers['internal-request-source'] = "fastlane"
837
+ status, message, response = retry_429_and_error do
838
+ response = connection.get(url) do |req|
839
+ req.headers['X-API-Token'] = api_token
840
+ req.headers['internal-request-source'] = "fastlane"
841
+ end
720
842
  end
721
843
 
722
- UI.message("DEBUG: #{response.status} #{JSON.pretty_generate(response.body)}\n") if ENV['DEBUG']
723
-
724
- case response.status
844
+ case status
845
+ when 0, 429
846
+ if status == 0
847
+ UI.error("Faraday http fetching destribution groups: #{message}")
848
+ else
849
+ UI.error("Retryable error fetching destribution groups: #{status}: #{message}")
850
+ end
851
+ false
725
852
  when 200...300
726
853
  response.body
727
854
  when 401
@@ -743,14 +870,21 @@ module Fastlane
743
870
 
744
871
  UI.message("DEBUG: GET #{url}") if ENV['DEBUG']
745
872
 
746
- response = connection.get(url) do |req|
747
- req.headers['X-API-Token'] = api_token
748
- req.headers['internal-request-source'] = "fastlane"
873
+ status, message, response = retry_429_and_error do
874
+ response = connection.get(url) do |req|
875
+ req.headers['X-API-Token'] = api_token
876
+ req.headers['internal-request-source'] = "fastlane"
877
+ end
749
878
  end
750
879
 
751
- UI.message("DEBUG: #{response.status} #{JSON.pretty_generate(response.body)}\n") if ENV['DEBUG']
752
-
753
- case response.status
880
+ case status
881
+ when 0, 429
882
+ if status == 0
883
+ UI.error("Faraday http fetching devices: #{message}")
884
+ else
885
+ UI.error("Retryable error fetching devices: #{status}: #{message}")
886
+ end
887
+ false
754
888
  when 200...300
755
889
  response.body
756
890
  when 401
@@ -772,26 +906,33 @@ module Fastlane
772
906
 
773
907
  UI.message("DEBUG: GET #{url}") if ENV['DEBUG']
774
908
 
775
- response = connection.get(url) do |req|
776
- req.headers['X-API-Token'] = api_token
777
- req.headers['internal-request-source'] = "fastlane"
909
+ status, message, response = retry_429_and_error do
910
+ response = connection.get(url) do |req|
911
+ req.headers['X-API-Token'] = api_token
912
+ req.headers['internal-request-source'] = "fastlane"
913
+ end
778
914
  end
779
915
 
780
- UI.message("DEBUG: #{response.status} #{JSON.pretty_generate(response.body)}\n") if ENV['DEBUG']
781
-
782
- case response.status
783
- when 200...300
784
- JSON.parse(response.body)
785
- when 401
786
- UI.user_error!("Auth Error, provided invalid token")
787
- false
788
- when 404
789
- UI.error("Not found, invalid owner or application name")
790
- false
791
- else
792
- UI.error("Error #{response.status}: #{response.body}")
793
- false
794
- end
916
+ case status
917
+ when 0, 429
918
+ if status == 0
919
+ UI.error("Faraday http fetching releases: #{message}")
920
+ else
921
+ UI.error("Retryable error fetching releases: #{status}: #{message}")
922
+ end
923
+ false
924
+ when 200...300
925
+ JSON.parse(response.body)
926
+ when 401
927
+ UI.user_error!("Auth Error, provided invalid token")
928
+ false
929
+ when 404
930
+ UI.error("Not found, invalid owner or application name")
931
+ false
932
+ else
933
+ UI.error("Error #{response.status}: #{response.body}")
934
+ false
935
+ end
795
936
  end
796
937
 
797
938
  def self.get_release_url(owner_type, owner_name, app_name, release_id)
@@ -824,17 +965,23 @@ module Fastlane
824
965
  UI.message("DEBUG: POST #{url}") if ENV['DEBUG']
825
966
  UI.message("DEBUG: POST body #{JSON.pretty_generate(body)}\n") if ENV['DEBUG']
826
967
 
827
- response = connection.post(url) do |req|
828
- req.headers['X-API-Token'] = api_token
829
- req.headers['internal-request-source'] = "fastlane"
830
- req.body = body
968
+ status, message, response = retry_429_and_error do
969
+ response = connection.post(url) do |req|
970
+ req.headers['X-API-Token'] = api_token
971
+ req.headers['internal-request-source'] = "fastlane"
972
+ req.body = body
973
+ end
831
974
  end
832
975
 
833
- UI.message("DEBUG: #{response.status} #{JSON.pretty_generate(response.body)}\n") if ENV['DEBUG']
834
-
835
- case response.status
976
+ case status
977
+ when 0, 429
978
+ if status == 0
979
+ UI.error("Faraday http adding to distribution group: #{message}")
980
+ else
981
+ UI.error("Retryable error adding to distribution group: #{status}: #{message}")
982
+ end
836
983
  when 200...300
837
- created = response.body
984
+ response.body
838
985
  UI.success("Added new app #{app_name} to distribution group #{destination_name}")
839
986
  when 401
840
987
  UI.user_error!("Auth Error, provided invalid token")
@@ -846,6 +993,38 @@ module Fastlane
846
993
  UI.error("Error adding app to distribution group #{response.status}: #{response.body}")
847
994
  end
848
995
  end
996
+
997
+ def self.retry_429_and_error(&block)
998
+ retries = 0
999
+ status = 0
1000
+
1001
+ # status == 0 - Faraday error
1002
+ # status == 429 - retryable error code from server
1003
+ while ((status == 0) || (status == 429)) && (retries <= MAX_REQUEST_RETRIES)
1004
+ begin
1005
+ # calling request sending logic
1006
+ response = block.call
1007
+
1008
+ # checking reponse
1009
+ status = response.status
1010
+ message = response.body
1011
+ UI.message("DEBUG: #{status} #{JSON.pretty_generate(message)}\n") if ENV['DEBUG']
1012
+ rescue Faraday::Error => e
1013
+ status = 0
1014
+ message = e.message
1015
+ end
1016
+
1017
+ # Pause before retrying
1018
+ if (status == 0) || (status == 429)
1019
+ sleep(REQUEST_RETRY_INTERVAL)
1020
+ end
1021
+
1022
+ retries += 1
1023
+ end
1024
+
1025
+ return status, message, response
1026
+ end
1027
+
849
1028
  end
850
1029
  end
851
1030
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Appcenter
3
- VERSION = "1.11.0"
3
+ VERSION = "1.11.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-appcenter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0
4
+ version: 1.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Microsoft Corporation
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-30 00:00:00.000000000 Z
11
+ date: 2021-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler