fastlane-plugin-sonarcloud_metric_kit 0.1.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eeddf4e49945c0dd9ea71e3e6226f7f3baea4fd1b7355f45c192776582acf528
|
4
|
+
data.tar.gz: f6d1000185737248180df90e63edaf85348cc6b675709e7e716b9a3501b6a9e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 =
|
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 =
|
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.
|
39
|
-
queries = "componentKey=#{params[:project_key]}
|
40
|
-
|
41
|
-
|
42
|
-
json_parse(
|
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.
|
46
|
-
|
47
|
-
|
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
|
-
'
|
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
|
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.
|
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
|
11
|
+
date: 2022-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|