fastlane-plugin-sentry 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: 33bc0c3cb58355cfad0087ef35c0583dcd30d608
4
- data.tar.gz: 51cd6de4e8ecc29e876fd11932d7947500ade905
3
+ metadata.gz: 254603126fe136f22cda805b86beb01ac197597a
4
+ data.tar.gz: 9acc2fe76b881829c9a8519652002f16176054d5
5
5
  SHA512:
6
- metadata.gz: 6a94d0a437671feed2a5cc8b6a30500f760ccb64f75feff98ca6efcaa3eb1efdeb1e20404e812618ec30c52179e07fdf02e8735b00f571c8442f88d649348894
7
- data.tar.gz: 3c57d653fb016c83b88f8d641cd5fbb08522191765a36edb60ab88f1f55297a8eb99a9b4cc25a6e311730fe7bfa853b73961a7eb157d1279cb1a3caaf6dcb497
6
+ metadata.gz: 6797c97ae2f62222f8600f86862a8d8fb592df44f388d284cb18e74f52dba8dac0f79e85faf5e1a7beb492999fb3e57501093a9be90b835268022c09cd279ff7
7
+ data.tar.gz: dcd3933d0e723ade6f6c1955871fda467b444047c6da18b40a540e8cc5b3f578aaf30d5f1faefbaeed7b71408057ab53d4a237458a7c4fd78160a8b0de4862c2
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # fastlane-plugin-sentry `fastlane` Plugin
2
2
 
3
3
  [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-sentry)
4
-
4
+ [![Build Status](https://img.shields.io/travis/getsentry/fastlane-plugin-sentry/master.svg?style=flat)](https://travis-ci.org/getsentry/fastlane-plugin-sentry)
5
5
 
6
6
  ## Getting Started
7
7
 
@@ -11,6 +11,8 @@ module Fastlane
11
11
  auth_token = params[:auth_token]
12
12
  org = params[:org_slug]
13
13
  project = params[:project_slug]
14
+ timeout = params[:timeout]
15
+ use_curl = params[:use_curl]
14
16
 
15
17
  # Params - dSYM
16
18
  dsym_path = params[:dsym_path]
@@ -28,11 +30,6 @@ module Fastlane
28
30
 
29
31
  # Url to post dSYMs to
30
32
  url = "#{host}/projects/#{org}/#{project}/files/dsyms/"
31
- if has_api_key
32
- resource = RestClient::Resource.new( url, api_key, '' )
33
- else
34
- resource = RestClient::Resource.new( url, headers: {Authorization: "Bearer #{auth_token}"} )
35
- end
36
33
 
37
34
  UI.message "Will upload dSYM(s) to #{url}"
38
35
 
@@ -45,29 +42,65 @@ module Fastlane
45
42
 
46
43
  # Upload dsym(s)
47
44
  uploaded_paths = dsym_paths.compact.map do |dsym|
48
- upload_dsym(resource, dsym)
45
+ upload_dsym(use_curl, dsym, url, timeout, api_key, auth_token)
49
46
  end
50
47
 
51
48
  # Return uplaoded dSYM paths
52
49
  uploaded_paths
53
50
  end
54
51
 
55
- def self.upload_dsym(resource, dsym)
52
+ def self.upload_dsym(use_curl, dsym, url, timeout, api_key, auth_token)
56
53
  UI.message "Uploading... #{dsym}"
57
- resource.post(file: File.new(dsym, 'rb')) unless Helper.test?
58
- UI.success 'dSYM successfully uploaded to Sentry!'
59
-
60
- dsym
61
- rescue RestClient::Exception => error
62
- handle_error(error, error.http_code)
63
- rescue => error
64
- handle_error(error)
54
+ if use_curl
55
+ self.upload_dsym_curl(dsym, url, timeout, api_key, auth_token)
56
+ else
57
+ self.upload_dsym_restclient(dsym, url, timeout, api_key, auth_token)
58
+ end
59
+ end
60
+
61
+ def self.upload_dsym_curl(dsym, url, timeout, api_key, auth_token)
62
+ has_api_key = !api_key.to_s.empty?
63
+
64
+ status = 0
65
+ if has_api_key
66
+ status = sh "curl -s -o /dev/null -w '%{response_code}' --max-time #{timeout} --user #{api_key}: -F file=@#{dsym} #{url} | grep -o '[1-4][0-9][0-9]' "
67
+ else
68
+ status = sh "curl -s -o /dev/null -w '%{response_code}' --max-time #{timeout} -H 'Authorization: Bearer #{auth_token}' -F file=@#{dsym} #{url} | grep -o '[1-4][0-9][0-9]' "
69
+ end
70
+
71
+ status = status.to_i
72
+ if (200..299).member?(status)
73
+ return dsym
74
+ else
75
+ self.handle_error(nil, status)
76
+ end
77
+ end
78
+
79
+ def self.upload_dsym_restclient(dsym, url, timeout, api_key, auth_token)
80
+ has_api_key = !api_key.to_s.empty?
81
+
82
+ if has_api_key
83
+ resource = RestClient::Resource.new( url, user: api_key, password: '', timeout: timeout, open_timeout: timeout )
84
+ else
85
+ resource = RestClient::Resource.new( url, headers: {Authorization: "Bearer #{auth_token}"}, timeout: timeout, open_timeout: timeout )
86
+ end
87
+
88
+ begin
89
+ resource.post(file: File.new(dsym, 'rb')) unless Helper.test?
90
+ UI.success 'dSYM successfully uploaded to Sentry!'
91
+ dsym
92
+ rescue RestClient::Exception => error
93
+ handle_error(error, error.http_code)
94
+ rescue => error
95
+ handle_error(error)
96
+ end
65
97
  end
66
98
 
67
99
  def self.handle_error(error, status = 0)
68
- UI.error "Error: #{error}"
100
+ UI.error "Error: #{error}" if error
69
101
  UI.important "Make sure your api_key or auth_token is configured correctly" if status == 401
70
102
  UI.important "Make sure the org_slug and project_slug matches exactly what is displayed your admin panel's URL" if status == 404
103
+ UI.important "Your upload may have timed out for an unknown reason" if status == 100
71
104
  UI.user_error! 'Error while trying to upload dSYM to Sentry'
72
105
  end
73
106
 
@@ -130,9 +163,28 @@ module Fastlane
130
163
  default_value: Actions.lane_context[SharedValues::DSYM_PATHS],
131
164
  is_string: false,
132
165
  optional: true,
166
+ verify_block: proc do |value|
167
+ # validation is done in the action
168
+ end),
169
+ FastlaneCore::ConfigItem.new(key: :timeout,
170
+ env_name: "SENTRY_TIMEOUT",
171
+ description: "Sentry upload API request timeout (in seconds)",
172
+ default_value: 120,
173
+ is_string: false,
174
+ optional: true,
175
+ verify_block: proc do |value|
176
+ # validation is done in the action
177
+ end),
178
+ FastlaneCore::ConfigItem.new(key: :use_curl,
179
+ env_name: "SENTRY_USE_CURL",
180
+ description: "Shells out the upload to `curl` instead of using `rest-client`. This MAY be needed for really large dSYM file sizes. Use this if you are receving timeouts",
181
+ default_value: false,
182
+ is_string: false,
183
+ optional: true,
133
184
  verify_block: proc do |value|
134
185
  # validation is done in the action
135
186
  end)
187
+
136
188
  ]
137
189
  end
138
190
 
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Sentry
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-sentry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Holtz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-13 00:00:00.000000000 Z
11
+ date: 2016-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -117,3 +117,4 @@ signing_key:
117
117
  specification_version: 4
118
118
  summary: Upload symbols to Sentry
119
119
  test_files: []
120
+ has_rdoc: