fastlane-plugin-youtrack 0.1.0 → 0.3.0
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 +4 -4
- data/lib/fastlane/plugin/youtrack/actions/yt_comment_issue_action.rb +96 -0
- data/lib/fastlane/plugin/youtrack/actions/yt_issues_info_action.rb +78 -27
- data/lib/fastlane/plugin/youtrack/actions/yt_set_issue_custom_field_value_action.rb +109 -0
- data/lib/fastlane/plugin/youtrack/helper/youtrack_helper.rb +47 -0
- data/lib/fastlane/plugin/youtrack/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63739100a15102a8154ce4b8a104229e05498267a3a8fb72bff732f3a9ca7fa4
|
4
|
+
data.tar.gz: 370c2da7869a2a25919e6af585f93fd2d33266e7d6e841cc66337f8977da39e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb43d2f3478621984dac2622c410488b469ea45401016b117c3b921bbc13cdaefb508f3ea98b898105ba42b23d74ab2e0bce146ef4d483825ac673cd5bdced69
|
7
|
+
data.tar.gz: 84f1a1264f078903a33c10c1b970acbd1dc6e77885f562af69a900a230a9406251763856b2606bf6576c2a60a786e195651a78c1c4575d1552e06439ee61d5e4
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/youtrack_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
class YtCommentIssueAction < Action
|
7
|
+
def self.run(params)
|
8
|
+
issue_id = params[:issue_id]
|
9
|
+
comment = params[:comment]
|
10
|
+
base_url = params[:base_url]
|
11
|
+
access_token = params[:access_token]
|
12
|
+
|
13
|
+
result = Helper::YoutrackHelper.comment_issue(issue_id, comment, base_url, access_token)
|
14
|
+
return {} unless result.success?
|
15
|
+
|
16
|
+
begin
|
17
|
+
response_body = JSON.parse(result.body)
|
18
|
+
rescue JSON::ParserError => e
|
19
|
+
puts e
|
20
|
+
end
|
21
|
+
|
22
|
+
response_body
|
23
|
+
rescue => ex
|
24
|
+
UI.error(ex)
|
25
|
+
UI.error('Failed')
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.description
|
29
|
+
'Add a comment to issue by passed identifier'
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.details
|
33
|
+
''
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.available_options
|
37
|
+
[
|
38
|
+
FastlaneCore::ConfigItem.new(
|
39
|
+
key: :issue_id,
|
40
|
+
description: 'Identifier of commented issue',
|
41
|
+
optional: false,
|
42
|
+
type: String
|
43
|
+
),
|
44
|
+
FastlaneCore::ConfigItem.new(
|
45
|
+
key: :comment,
|
46
|
+
description: 'Text of comment',
|
47
|
+
optional: false,
|
48
|
+
type: String
|
49
|
+
),
|
50
|
+
FastlaneCore::ConfigItem.new(
|
51
|
+
key: :base_url,
|
52
|
+
env_name: 'YOUTRACK_BASE_URL',
|
53
|
+
description: 'Base YouTrack URL',
|
54
|
+
optional: false,
|
55
|
+
type: String
|
56
|
+
),
|
57
|
+
FastlaneCore::ConfigItem.new(
|
58
|
+
key: :access_token,
|
59
|
+
env_name: 'YOUTRACK_API_TOKEN',
|
60
|
+
description: 'Access token for YouTrack API',
|
61
|
+
optional: false,
|
62
|
+
type: String
|
63
|
+
)
|
64
|
+
]
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.return_value
|
68
|
+
'Nothing'
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.authors
|
72
|
+
['Semen Kologrivov']
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.is_supported?(_)
|
76
|
+
true
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.example_code
|
80
|
+
[
|
81
|
+
'yt_comment_issue(issue_id: "ios_1234", comment: "Lorem ipsum")'
|
82
|
+
]
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.output
|
86
|
+
[
|
87
|
+
[]
|
88
|
+
]
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.return_type
|
92
|
+
:array
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -8,21 +8,57 @@ module Fastlane
|
|
8
8
|
end
|
9
9
|
class YtIssuesInfoAction < Action
|
10
10
|
def self.run(params)
|
11
|
-
|
11
|
+
issue_ids = params[:issue_ids]
|
12
12
|
fields = params[:issue_fields]
|
13
|
+
custom_fields_names = params[:issue_custom_fields_names]
|
13
14
|
base_url = params[:base_url]
|
14
15
|
access_token = params[:access_token]
|
15
16
|
|
16
|
-
issues_info =
|
17
|
+
issues_info = issue_ids.map do |issue_id|
|
17
18
|
info = {
|
19
|
+
id: issue_id,
|
18
20
|
url: "#{base_url}/issue/#{issue_id}"
|
19
21
|
}
|
20
|
-
|
21
|
-
|
22
|
+
|
23
|
+
issue_info_result = Helper::YoutrackHelper.get_issue_info(
|
24
|
+
issue_id,
|
25
|
+
fields,
|
26
|
+
base_url,
|
27
|
+
access_token
|
28
|
+
)
|
29
|
+
return info unless issue_info_result.success?
|
22
30
|
|
23
31
|
begin
|
24
|
-
|
25
|
-
fields.each { |field| info[field.to_sym] =
|
32
|
+
issue_info_response_body = JSON.parse(issue_info_result.body)
|
33
|
+
fields.each { |field| info[field.to_sym] = issue_info_response_body[field] }
|
34
|
+
rescue JSON::ParserError => e
|
35
|
+
puts e
|
36
|
+
return info
|
37
|
+
end
|
38
|
+
|
39
|
+
issue_custom_fields_result = Helper::YoutrackHelper.get_issue_custom_fields(
|
40
|
+
issue_id,
|
41
|
+
base_url,
|
42
|
+
access_token
|
43
|
+
)
|
44
|
+
|
45
|
+
return info unless issue_custom_fields_result.success?
|
46
|
+
|
47
|
+
begin
|
48
|
+
issue_custom_fields_response_body = JSON.parse(issue_custom_fields_result.body)
|
49
|
+
custom_fields_names.each do |field_name|
|
50
|
+
custom_field = issue_custom_fields_response_body.find { |field|
|
51
|
+
field['name'] == field_name
|
52
|
+
}
|
53
|
+
|
54
|
+
next if custom_field.nil?
|
55
|
+
|
56
|
+
info[field_name.to_sym] = {
|
57
|
+
type: custom_field['$type'],
|
58
|
+
name: custom_field['name'],
|
59
|
+
value: custom_field['value']['name']
|
60
|
+
}
|
61
|
+
end
|
26
62
|
rescue JSON::ParserError => e
|
27
63
|
puts e
|
28
64
|
return info
|
@@ -33,7 +69,7 @@ module Fastlane
|
|
33
69
|
|
34
70
|
Actions.lane_context[SharedValues::YOUTRACK_RELEASED_ISSUES] = issues_info
|
35
71
|
|
36
|
-
|
72
|
+
issues_info
|
37
73
|
rescue => ex
|
38
74
|
UI.error(ex)
|
39
75
|
UI.error('Failed')
|
@@ -49,25 +85,40 @@ module Fastlane
|
|
49
85
|
|
50
86
|
def self.available_options
|
51
87
|
[
|
52
|
-
FastlaneCore::ConfigItem.new(
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
88
|
+
FastlaneCore::ConfigItem.new(
|
89
|
+
key: :issue_ids,
|
90
|
+
description: 'Array of issue\'s ids',
|
91
|
+
optional: false,
|
92
|
+
type: Array
|
93
|
+
),
|
94
|
+
FastlaneCore::ConfigItem.new(
|
95
|
+
key: :issue_fields,
|
96
|
+
description: 'Array of neccessary fields of issue',
|
97
|
+
optional: true,
|
98
|
+
default_value: ['summary', 'description'],
|
99
|
+
type: Array
|
100
|
+
),
|
101
|
+
FastlaneCore::ConfigItem.new(
|
102
|
+
key: :issue_custom_fields_names,
|
103
|
+
description: 'Array of names of neccessary custom fields of issue',
|
104
|
+
optional: true,
|
105
|
+
default_value: ['Kanban State', 'Stage'],
|
106
|
+
type: Array
|
107
|
+
),
|
108
|
+
FastlaneCore::ConfigItem.new(
|
109
|
+
key: :base_url,
|
110
|
+
env_name: 'YOUTRACK_BASE_URL',
|
111
|
+
description: 'Base YouTrack URL',
|
112
|
+
optional: false,
|
113
|
+
type: String
|
114
|
+
),
|
115
|
+
FastlaneCore::ConfigItem.new(
|
116
|
+
key: :access_token,
|
117
|
+
env_name: 'YOUTRACK_API_TOKEN',
|
118
|
+
description: 'Access token for YouTrack API',
|
119
|
+
optional: false,
|
120
|
+
type: String
|
121
|
+
)
|
71
122
|
]
|
72
123
|
end
|
73
124
|
|
@@ -100,4 +151,4 @@ module Fastlane
|
|
100
151
|
end
|
101
152
|
end
|
102
153
|
end
|
103
|
-
end
|
154
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/youtrack_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
class YtSetIssueCustomFieldValueAction < Action
|
7
|
+
def self.run(params)
|
8
|
+
issue_id = params[:issue_id]
|
9
|
+
field = params[:field]
|
10
|
+
field_value = params[:field_value]
|
11
|
+
base_url = params[:base_url]
|
12
|
+
access_token = params[:access_token]
|
13
|
+
|
14
|
+
result = Helper::YoutrackHelper.set_custom_field_value(
|
15
|
+
issue_id,
|
16
|
+
field,
|
17
|
+
field_value,
|
18
|
+
base_url,
|
19
|
+
access_token
|
20
|
+
)
|
21
|
+
return {} unless result.success?
|
22
|
+
|
23
|
+
begin
|
24
|
+
response_body = JSON.parse(result.body)
|
25
|
+
rescue JSON::ParserError => e
|
26
|
+
puts e
|
27
|
+
end
|
28
|
+
|
29
|
+
response_body
|
30
|
+
rescue => ex
|
31
|
+
UI.error(ex)
|
32
|
+
UI.error('Failed')
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.description
|
36
|
+
'Set value for passed custom field name'
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.details
|
40
|
+
''
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.available_options
|
44
|
+
[
|
45
|
+
FastlaneCore::ConfigItem.new(
|
46
|
+
key: :issue_id,
|
47
|
+
description: 'Identifier of issue',
|
48
|
+
optional: false,
|
49
|
+
type: String
|
50
|
+
),
|
51
|
+
FastlaneCore::ConfigItem.new(
|
52
|
+
key: :field,
|
53
|
+
description: 'Custom field info',
|
54
|
+
optional: false,
|
55
|
+
type: Hash
|
56
|
+
),
|
57
|
+
FastlaneCore::ConfigItem.new(
|
58
|
+
key: :field_value,
|
59
|
+
description: 'Value of custom field',
|
60
|
+
optional: false,
|
61
|
+
type: String
|
62
|
+
),
|
63
|
+
FastlaneCore::ConfigItem.new(
|
64
|
+
key: :base_url,
|
65
|
+
env_name: 'YOUTRACK_BASE_URL',
|
66
|
+
description: 'Base YouTrack URL',
|
67
|
+
optional: false,
|
68
|
+
type: String
|
69
|
+
),
|
70
|
+
FastlaneCore::ConfigItem.new(
|
71
|
+
key: :access_token,
|
72
|
+
env_name: 'YOUTRACK_API_TOKEN',
|
73
|
+
description: 'Access token for YouTrack API',
|
74
|
+
optional: false,
|
75
|
+
type: String
|
76
|
+
)
|
77
|
+
]
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.return_value
|
81
|
+
'Nothing'
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.authors
|
85
|
+
['Semen Kologrivov']
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.is_supported?(_)
|
89
|
+
true
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.example_code
|
93
|
+
[
|
94
|
+
'yt_set_issue_custom_field_value(issue_id: "ios_1234", field_name: "Foo", field_value: "Bar")'
|
95
|
+
]
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.output
|
99
|
+
[
|
100
|
+
[]
|
101
|
+
]
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.return_type
|
105
|
+
:array
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -19,6 +19,53 @@ module Fastlane
|
|
19
19
|
req.headers['Authorization'] = "Bearer #{token}"
|
20
20
|
end
|
21
21
|
end
|
22
|
+
|
23
|
+
def self.get_issue_custom_fields(issue_id, url, token)
|
24
|
+
Faraday.get("#{url}/api/issues/#{issue_id}/customFields") do |req|
|
25
|
+
req.params['fields'] = 'id,name,value(id,name)'
|
26
|
+
|
27
|
+
req.headers['Content-Type'] = 'application/json'
|
28
|
+
req.headers['Accept'] = 'application/json'
|
29
|
+
req.headers['Cache-Control'] = 'no-cache'
|
30
|
+
req.headers['Authorization'] = "Bearer #{token}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.comment_issue(issue_id, comment, url, token)
|
35
|
+
Faraday.post("#{url}/api/issues/#{issue_id}/comments") do |req|
|
36
|
+
body = {
|
37
|
+
text: comment
|
38
|
+
}
|
39
|
+
req.body = JSON.generate(body)
|
40
|
+
|
41
|
+
req.headers['Content-Type'] = 'application/json'
|
42
|
+
req.headers['Accept'] = 'application/json'
|
43
|
+
req.headers['Cache-Control'] = 'no-cache'
|
44
|
+
req.headers['Authorization'] = "Bearer #{token}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.set_custom_field_value(issue_id, field, field_value, url, token)
|
49
|
+
Faraday.post("#{url}/api/issues/#{issue_id}") do |req|
|
50
|
+
body = {
|
51
|
+
'customFields' => [
|
52
|
+
{
|
53
|
+
'name' => field[:name],
|
54
|
+
'$type' => field[:type],
|
55
|
+
'value' => {
|
56
|
+
'name' => field_value
|
57
|
+
}
|
58
|
+
}
|
59
|
+
]
|
60
|
+
}
|
61
|
+
req.body = JSON.generate(body)
|
62
|
+
|
63
|
+
req.headers['Content-Type'] = 'application/json'
|
64
|
+
req.headers['Accept'] = 'application/json'
|
65
|
+
req.headers['Cache-Control'] = 'no-cache'
|
66
|
+
req.headers['Authorization'] = "Bearer #{token}"
|
67
|
+
end
|
68
|
+
end
|
22
69
|
end
|
23
70
|
end
|
24
71
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-youtrack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Semen Kologrivov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -137,7 +137,7 @@ dependencies:
|
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 2.172.0
|
139
139
|
description:
|
140
|
-
email:
|
140
|
+
email: semen@sequenia.com
|
141
141
|
executables: []
|
142
142
|
extensions: []
|
143
143
|
extra_rdoc_files: []
|
@@ -145,7 +145,9 @@ files:
|
|
145
145
|
- LICENSE
|
146
146
|
- README.md
|
147
147
|
- lib/fastlane/plugin/youtrack.rb
|
148
|
+
- lib/fastlane/plugin/youtrack/actions/yt_comment_issue_action.rb
|
148
149
|
- lib/fastlane/plugin/youtrack/actions/yt_issues_info_action.rb
|
150
|
+
- lib/fastlane/plugin/youtrack/actions/yt_set_issue_custom_field_value_action.rb
|
149
151
|
- lib/fastlane/plugin/youtrack/helper/youtrack_helper.rb
|
150
152
|
- lib/fastlane/plugin/youtrack/version.rb
|
151
153
|
homepage:
|
@@ -167,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
169
|
- !ruby/object:Gem::Version
|
168
170
|
version: '0'
|
169
171
|
requirements: []
|
170
|
-
rubygems_version: 3.
|
172
|
+
rubygems_version: 3.1.6
|
171
173
|
signing_key:
|
172
174
|
specification_version: 4
|
173
175
|
summary: Use for communicating with YouTrack (fetching issue's info, adding comments
|