fastlane-plugin-sonarcloud_metric_kit 0.1.1 → 0.2.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: 7c0c5f65d4d9a28b71b7167801b1e482c6e5ebbca7a46004014d1beef6865011
4
- data.tar.gz: 29b278995c38d9f31b62b7de49be795ce20298d385ec3bd420bed1018ff47f46
3
+ metadata.gz: eeddf4e49945c0dd9ea71e3e6226f7f3baea4fd1b7355f45c192776582acf528
4
+ data.tar.gz: f6d1000185737248180df90e63edaf85348cc6b675709e7e716b9a3501b6a9e3
5
5
  SHA512:
6
- metadata.gz: 58685710cb6749e958f13bb529cd7d61ee5d7803c01e50489c0d1595024851fbf8554be0ec2e03f5a69098dc3a32baa2ae90e4e0838410cb4a65df42530fead2
7
- data.tar.gz: aa9c2dc590a96dcd806dbfb442cb6c4e1a39b72d2374aebd598ad859a44783991de79b8628aecdb0bc5dabb4fe0d3bb2f23af9e2d95dc40c33f642ea631e0514
6
+ metadata.gz: 3e30412bc28b7e662d7a74afd3e8b1dc0f9a5853e302007d59fb92786c1146a09ba6fb371b549063f30fb80f220285fd98f3be90dbcf564cef05464322d52130
7
+ data.tar.gz: 333dfb9c82f53c3737f887692fdba2b560db75dc63c994fe429a488f3ac3abb181cc53c5d59ed8c6cae63d482d68637c324ad0ac76b40ac775dde44eb2d0cf6d
@@ -13,9 +13,11 @@ module Fastlane
13
13
 
14
14
  def self.collect_metrics(params)
15
15
  metrics = {}
16
- measures = measures(params)
16
+ measures = get_measures(params)
17
17
  metric_keys.each do |key|
18
18
  metric = measures.find { |m| m['metric'] == key.to_s }
19
+ next unless metric
20
+
19
21
  metrics[key.to_sym] =
20
22
  if metric['value']
21
23
  metric['value']
@@ -27,7 +29,7 @@ module Fastlane
27
29
  end
28
30
  return metrics unless params[:quality_gate]
29
31
 
30
- quality_gate = quality_gate(params)
32
+ quality_gate = get_quality_gate(params)
31
33
  metrics[:quality_gate] = quality_gate
32
34
  if params[:period] && quality_gate['periods'].size > params[:period]
33
35
  metrics[:period_value] = quality_gate['periods'][params[:period]]['parameter']
@@ -35,16 +37,22 @@ module Fastlane
35
37
  metrics
36
38
  end
37
39
 
38
- def self.measures(params)
39
- queries = "componentKey=#{params[:project_key]}&metricKeys=#{metric_keys.join(',')}"
40
- url = URI("#{api_url}/measures/component?#{queries}")
41
- response = request(url, token: params[:sonar_token])
42
- json_parse(response.read_body)['component']['measures']
40
+ def self.get_measures(params)
41
+ queries = ["componentKey=#{params[:project_key]}", "metricKeys=#{metric_keys.join(',')}"]
42
+ queries << "branch=#{params[:branch]}" if params[:branch]
43
+ url = URI("#{api_url}/measures/component?#{queries.join('&')}")
44
+ response = json_parse(request(url, token: params[:sonar_token]).read_body)
45
+ UI.user_error!(response) unless response['component']
46
+ response['component']['measures']
43
47
  end
44
48
 
45
- def self.quality_gate(params)
46
- url = URI("#{api_url}/qualitygates/project_status?projectKey=#{params[:project_key]}")
47
- JSON.parse(request(url, token: params[:sonar_token]).read_body)['projectStatus']
49
+ def self.get_quality_gate(params)
50
+ queries = ["projectKey=#{params[:project_key]}"]
51
+ queries << "branch=#{params[:branch]}" if params[:branch]
52
+ url = URI("#{api_url}/qualitygates/project_status?#{queries.join('&')}")
53
+ response = json_parse(request(url, token: params[:sonar_token]).read_body)
54
+ UI.user_error!(response) unless response['projectStatus']
55
+ response['projectStatus']
48
56
  end
49
57
 
50
58
  def self.request(url, token:)
@@ -136,7 +144,7 @@ module Fastlane
136
144
  #####################################################
137
145
 
138
146
  def self.description
139
- 'Generates a report from SonarCloud'
147
+ 'Collects metrics from SonarCloud'
140
148
  end
141
149
 
142
150
  def self.available_options
@@ -166,6 +174,12 @@ module Fastlane
166
174
  is_string: false,
167
175
  optional: true,
168
176
  default_value: false
177
+ ),
178
+ FastlaneCore::ConfigItem.new(
179
+ key: :branch,
180
+ description: 'Git branch to use for collecting metrics',
181
+ is_string: true,
182
+ optional: true
169
183
  )
170
184
  ]
171
185
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module SonarcloudMetricKit
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-sonarcloud_metric_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - alteral
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-22 00:00:00.000000000 Z
11
+ date: 2022-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler