fastlane-plugin-jira_fetch_tickets 0.1.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 +7 -0
- data/LICENSE +21 -0
- data/README.md +52 -0
- data/lib/fastlane/plugin/jira_fetch_tickets/actions/jira_fetch_tickets_action.rb +274 -0
- data/lib/fastlane/plugin/jira_fetch_tickets/helper/jira_fetch_tickets_helper.rb +16 -0
- data/lib/fastlane/plugin/jira_fetch_tickets/version.rb +5 -0
- data/lib/fastlane/plugin/jira_fetch_tickets.rb +16 -0
- metadata +49 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 527b5e571224926a0340d61568456d9bc7d4952e9192a8cc788077ceeef19350
|
4
|
+
data.tar.gz: ddfef4f47585103f70034b47bbffa6968678b0a7f48e724d62e9abfe87c32fcf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 307121a63096d8163fc166d540d6165fc5a3561530615a9aa0800565f31627acfc35e3748713d6f0da685a8da79e57a4d637c7767515d9e6e227aa25853e3fa0
|
7
|
+
data.tar.gz: 9952e9cf8094bbdc2489c1404eb76c98f00b6abeacb271190404d83e961e284f488c774fca176918b3f71c69e34b7b3374d7c71f0c2376ce1c26a7cf716ee24a
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Luca Tagliabue <lu.tagliabue@reply.it>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# jira_fetch_tickets plugin
|
2
|
+
|
3
|
+
[](https://rubygems.org/gems/fastlane-plugin-jira_fetch_tickets)
|
4
|
+
|
5
|
+
## Getting Started
|
6
|
+
|
7
|
+
This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-jira_fetch_tickets`, add it to your project by running:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
fastlane add_plugin jira_fetch_tickets
|
11
|
+
```
|
12
|
+
|
13
|
+
## About jira_fetch_tickets
|
14
|
+
|
15
|
+
Fetch ticekts on jira project using jql query
|
16
|
+
|
17
|
+
**Note to author:** Add a more detailed description about this plugin here. If your plugin contains multiple actions, make sure to mention them here.
|
18
|
+
|
19
|
+
## Example
|
20
|
+
|
21
|
+
Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
|
22
|
+
|
23
|
+
**Note to author:** Please set up a sample project to make it easy for users to explore what your plugin does. Provide everything that is necessary to try out the plugin in this project (including a sample Xcode/Android project if necessary)
|
24
|
+
|
25
|
+
## Run tests for this plugin
|
26
|
+
|
27
|
+
To run both the tests, and code style validation, run
|
28
|
+
|
29
|
+
```
|
30
|
+
rake
|
31
|
+
```
|
32
|
+
|
33
|
+
To automatically fix many of the styling issues, use
|
34
|
+
```
|
35
|
+
rubocop -a
|
36
|
+
```
|
37
|
+
|
38
|
+
## Issues and Feedback
|
39
|
+
|
40
|
+
For any other issues and feedback about this plugin, please submit it to this repository.
|
41
|
+
|
42
|
+
## Troubleshooting
|
43
|
+
|
44
|
+
If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
|
45
|
+
|
46
|
+
## Using _fastlane_ Plugins
|
47
|
+
|
48
|
+
For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
|
49
|
+
|
50
|
+
## About _fastlane_
|
51
|
+
|
52
|
+
_fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
|
@@ -0,0 +1,274 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require 'fastlane_core'
|
3
|
+
require_relative '../helper/jira_fetch_tickets_helper'
|
4
|
+
|
5
|
+
module Fastlane
|
6
|
+
module Actions
|
7
|
+
module SharedValues
|
8
|
+
JIRA_FETCH_TICKETS_RESULT = :JIRA_FETCH_TICKETS_RESULT
|
9
|
+
end
|
10
|
+
|
11
|
+
class JiraFetchTicketsAction < Action
|
12
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
13
|
+
def self.run(params)
|
14
|
+
Actions.verify_gem!('jira-ruby')
|
15
|
+
require 'jira-ruby'
|
16
|
+
|
17
|
+
client = JIRA::Client.new(
|
18
|
+
username: params[:username],
|
19
|
+
password: params[:password],
|
20
|
+
site: params[:url],
|
21
|
+
context_path: '',
|
22
|
+
auth_type: :basic
|
23
|
+
)
|
24
|
+
|
25
|
+
projects = params[:projects]
|
26
|
+
project = params[:project]
|
27
|
+
statuses = params[:statuses]
|
28
|
+
status = params[:status]
|
29
|
+
labels = params[:labels]
|
30
|
+
label = params[:label]
|
31
|
+
sprints = params[:sprints]
|
32
|
+
sprint = params[:sprint]
|
33
|
+
custom_jql = params[:custom_jql]
|
34
|
+
|
35
|
+
jql = ""
|
36
|
+
|
37
|
+
unless projects.instance_of?(NilClass)
|
38
|
+
options = { key: "project", values: projects }
|
39
|
+
jql = jql_from_array?(options)
|
40
|
+
end
|
41
|
+
|
42
|
+
if jql.empty? && !project.instance_of?(NilClass)
|
43
|
+
options = { key: "project", value: project }
|
44
|
+
jql = jql_from_string?(options)
|
45
|
+
end
|
46
|
+
|
47
|
+
added = false
|
48
|
+
unless statuses.instance_of?(NilClass)
|
49
|
+
options = { key: "status", values: statuses, jql: jql }
|
50
|
+
jql = append_jql_from_array?(options)
|
51
|
+
added = true
|
52
|
+
end
|
53
|
+
|
54
|
+
if !added && !status.instance_of?(NilClass)
|
55
|
+
options = { key: "status", value: status, jql: jql }
|
56
|
+
jql = append_jql_from_string?(options)
|
57
|
+
end
|
58
|
+
|
59
|
+
added = false
|
60
|
+
unless labels.instance_of?(NilClass)
|
61
|
+
options = { key: "labels", values: labels, jql: jql }
|
62
|
+
jql = append_jql_from_array?(options)
|
63
|
+
added = true
|
64
|
+
end
|
65
|
+
|
66
|
+
if !added && !label.instance_of?(NilClass)
|
67
|
+
options = { key: "labels", value: label, jql: jql }
|
68
|
+
jql = append_jql_from_string?(options)
|
69
|
+
end
|
70
|
+
|
71
|
+
added = false
|
72
|
+
unless sprints.instance_of?(NilClass)
|
73
|
+
options = { key: "Sprint", values: sprints, jql: jql }
|
74
|
+
jql = append_jql_from_array?(options)
|
75
|
+
added = true
|
76
|
+
end
|
77
|
+
|
78
|
+
if !added && !sprint.instance_of?(NilClass)
|
79
|
+
options = { key: "Sprint", value: sprint, jql: jql }
|
80
|
+
jql = append_jql_from_string?(options)
|
81
|
+
end
|
82
|
+
|
83
|
+
if custom_jql
|
84
|
+
options = { jql: jql, new_value: custom_jql }
|
85
|
+
jql = append_jql?(options)
|
86
|
+
end
|
87
|
+
|
88
|
+
UI.message("JQL query is '#{jql}'")
|
89
|
+
|
90
|
+
issues = client.Issue.jql(jql)
|
91
|
+
|
92
|
+
issues = issues.map do |issue|
|
93
|
+
{ key: issue.key, issue: issue.attrs }
|
94
|
+
end
|
95
|
+
|
96
|
+
Actions.lane_context[SharedValues::JIRA_FETCH_TICKETS_RESULT] = issues
|
97
|
+
|
98
|
+
UI.success('Successfully fetched JIRA tickets!')
|
99
|
+
issues
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.jql_from_array?(options)
|
103
|
+
values = options[:values]
|
104
|
+
values = values.map { |string| "\"#{string}\"" }
|
105
|
+
"#{options[:key]} in (#{values.join(', ')})"
|
106
|
+
end
|
107
|
+
|
108
|
+
def self.append_jql_from_array?(options)
|
109
|
+
jql = options[:jql]
|
110
|
+
options = { key: options[:key], values: options[:values] }
|
111
|
+
to_append = jql_from_array?(options)
|
112
|
+
options = { jql: jql, new_value: to_append }
|
113
|
+
append_jql?(options)
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.jql_from_string?(options)
|
117
|
+
"#{options[:key]} = \"#{options[:value]}\""
|
118
|
+
end
|
119
|
+
|
120
|
+
def self.append_jql_from_string?(options)
|
121
|
+
jql = options[:jql]
|
122
|
+
options = { key: options[:key], value: options[:value] }
|
123
|
+
to_append = jql_from_string?(options)
|
124
|
+
options = { jql: jql, new_value: to_append }
|
125
|
+
append_jql?(options)
|
126
|
+
end
|
127
|
+
|
128
|
+
def self.append_jql?(options)
|
129
|
+
jql = options[:jql]
|
130
|
+
new_value = options[:new_value]
|
131
|
+
|
132
|
+
appended = ""
|
133
|
+
if jql.empty?
|
134
|
+
appended = new_value
|
135
|
+
else
|
136
|
+
appended = "#{jql} AND #{new_value}"
|
137
|
+
end
|
138
|
+
|
139
|
+
appended
|
140
|
+
end
|
141
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
142
|
+
|
143
|
+
def self.description
|
144
|
+
"Fetch ticekts on jira project using jql query"
|
145
|
+
end
|
146
|
+
|
147
|
+
def self.authors
|
148
|
+
["Luca Tagliabue"]
|
149
|
+
end
|
150
|
+
|
151
|
+
def self.return_value
|
152
|
+
"Hash object of key and issue."
|
153
|
+
end
|
154
|
+
|
155
|
+
def self.output
|
156
|
+
[
|
157
|
+
['JIRA_FETCH_TICKETS_RESULT', 'Hash object of key and issue.']
|
158
|
+
]
|
159
|
+
end
|
160
|
+
|
161
|
+
def self.details
|
162
|
+
"Fetch ticekts on jira project using jql query"
|
163
|
+
end
|
164
|
+
|
165
|
+
def self.available_options
|
166
|
+
[
|
167
|
+
FastlaneCore::ConfigItem.new(key: :url,
|
168
|
+
env_name: "FL_JIRA_SITE",
|
169
|
+
description: "URL for Jira instance",
|
170
|
+
sensitive: true,
|
171
|
+
type: String,
|
172
|
+
verify_block: ->(value) { verify_option(key: 'url', value: value) }),
|
173
|
+
FastlaneCore::ConfigItem.new(key: :username,
|
174
|
+
env_name: "FL_JIRA_USERNAME",
|
175
|
+
description: "Username for Jira instance",
|
176
|
+
sensitive: true,
|
177
|
+
type: String,
|
178
|
+
verify_block: ->(value) { verify_option(key: 'username', value: value) }),
|
179
|
+
FastlaneCore::ConfigItem.new(key: :password,
|
180
|
+
env_name: "FL_JIRA_PASSWORD",
|
181
|
+
description: "Password or api token for Jira",
|
182
|
+
sensitive: true,
|
183
|
+
type: String,
|
184
|
+
verify_block: ->(value) { verify_option(key: 'password', value: value) }),
|
185
|
+
FastlaneCore::ConfigItem.new(key: :projects,
|
186
|
+
env_name: "FL_JIRA_FETCH_JQL_PROJECTS",
|
187
|
+
description: "Array of Jira projects",
|
188
|
+
type: Array,
|
189
|
+
optional: true),
|
190
|
+
FastlaneCore::ConfigItem.new(key: :project,
|
191
|
+
env_name: "FL_JIRA_FETCH_JQL_PROJECT",
|
192
|
+
description: "Jira project",
|
193
|
+
type: String,
|
194
|
+
optional: true,
|
195
|
+
conflicting_options: [:projects],
|
196
|
+
conflict_block: proc do |other|
|
197
|
+
UI.message("Ignoring :project in favor of :projects")
|
198
|
+
end),
|
199
|
+
FastlaneCore::ConfigItem.new(key: :statuses,
|
200
|
+
env_name: "FL_JIRA_FETCH_JQL_STATUSES",
|
201
|
+
description: "Array of Jira status",
|
202
|
+
type: Array,
|
203
|
+
optional: true),
|
204
|
+
FastlaneCore::ConfigItem.new(key: :status,
|
205
|
+
env_name: "FL_JIRA_FETCH_JQL_STATUS",
|
206
|
+
description: "Jira status",
|
207
|
+
type: String,
|
208
|
+
optional: true,
|
209
|
+
conflicting_options: [:statuses],
|
210
|
+
conflict_block: proc do |other|
|
211
|
+
UI.message("Ignoring :status in favor of :statuses")
|
212
|
+
end),
|
213
|
+
FastlaneCore::ConfigItem.new(key: :labels,
|
214
|
+
env_name: "FL_JIRA_FETCH_JQL_LABELS",
|
215
|
+
description: "Array of Jira labels",
|
216
|
+
type: Array,
|
217
|
+
optional: true),
|
218
|
+
FastlaneCore::ConfigItem.new(key: :label,
|
219
|
+
env_name: "FL_JIRA_FETCH_JQL_LABEL",
|
220
|
+
description: "Jira label",
|
221
|
+
type: String,
|
222
|
+
optional: true,
|
223
|
+
conflicting_options: [:labels],
|
224
|
+
conflict_block: proc do |other|
|
225
|
+
UI.message("Ignoring :label in favor of :labels")
|
226
|
+
end),
|
227
|
+
FastlaneCore::ConfigItem.new(key: :sprints,
|
228
|
+
env_name: "FL_JIRA_FETCH_JQL_SPRINTS",
|
229
|
+
description: "Jira sprints",
|
230
|
+
type: Array,
|
231
|
+
optional: true),
|
232
|
+
FastlaneCore::ConfigItem.new(key: :sprint,
|
233
|
+
env_name: "FL_JIRA_FETCH_JQL_SPRINT",
|
234
|
+
description: "Jira sprint",
|
235
|
+
type: String,
|
236
|
+
optional: true,
|
237
|
+
conflicting_options: [:sprints],
|
238
|
+
conflict_block: proc do |other|
|
239
|
+
UI.message("Ignoring :sprint in favor of :sprints")
|
240
|
+
end),
|
241
|
+
FastlaneCore::ConfigItem.new(key: :custom_jql,
|
242
|
+
env_name: "FL_JIRA_FETCH_JQL_CUSTOM",
|
243
|
+
description: "Jira custom jql",
|
244
|
+
type: String,
|
245
|
+
optional: true)
|
246
|
+
]
|
247
|
+
end
|
248
|
+
|
249
|
+
def self.verify_option(options)
|
250
|
+
UI.user_error!("No value found for '#{options[:key]}'") if options[:value].to_s.empty?
|
251
|
+
end
|
252
|
+
|
253
|
+
def self.example_code
|
254
|
+
[
|
255
|
+
'jira_fetch_tickets(
|
256
|
+
url: "YOUR_URL_HERE",
|
257
|
+
username: "YOUR_USERNAME_HERE",
|
258
|
+
password: "YOUR_PASSWORD_HERE",
|
259
|
+
project: "YOUR_PROJECT_HERE",
|
260
|
+
status: "STATUS_HERE",
|
261
|
+
label: "LABEL_HERE",
|
262
|
+
sprint: "SPRINT_HERE",
|
263
|
+
custom_jql: "CUSTOM_JQL_HERE"
|
264
|
+
)'
|
265
|
+
]
|
266
|
+
end
|
267
|
+
# rubocop:enable Metrics/MethodLength
|
268
|
+
|
269
|
+
def self.is_supported?(platform)
|
270
|
+
true
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'fastlane_core/ui/ui'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
UI = FastlaneCore::UI unless Fastlane.const_defined?(:UI)
|
5
|
+
|
6
|
+
module Helper
|
7
|
+
class JiraFetchTicketsHelper
|
8
|
+
# class methods that you define here become available in your action
|
9
|
+
# as `Helper::JiraFetchTicketsHelper.your_method`
|
10
|
+
#
|
11
|
+
def self.show_message
|
12
|
+
UI.message("Hello from the jira_fetch_tickets plugin helper!")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'fastlane/plugin/jira_fetch_tickets/version'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
module JiraFetchTickets
|
5
|
+
# Return all .rb files inside the "actions" and "helper" directory
|
6
|
+
def self.all_classes
|
7
|
+
Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# By default we want to import all available actions and helpers
|
13
|
+
# A plugin can contain any number of actions and plugins
|
14
|
+
Fastlane::JiraFetchTickets.all_classes.each do |current|
|
15
|
+
require current
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fastlane-plugin-jira_fetch_tickets
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Luca Tagliabue
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-03-19 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email: homobonus-luca@hotmail.it
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- LICENSE
|
20
|
+
- README.md
|
21
|
+
- lib/fastlane/plugin/jira_fetch_tickets.rb
|
22
|
+
- lib/fastlane/plugin/jira_fetch_tickets/actions/jira_fetch_tickets_action.rb
|
23
|
+
- lib/fastlane/plugin/jira_fetch_tickets/helper/jira_fetch_tickets_helper.rb
|
24
|
+
- lib/fastlane/plugin/jira_fetch_tickets/version.rb
|
25
|
+
homepage: https://github.com/lukluca/fastlane-plugin-jira_fetch_tickets
|
26
|
+
licenses:
|
27
|
+
- MIT
|
28
|
+
metadata:
|
29
|
+
rubygems_mfa_required: 'true'
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '2.6'
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
requirements: []
|
45
|
+
rubygems_version: 3.5.4
|
46
|
+
signing_key:
|
47
|
+
specification_version: 4
|
48
|
+
summary: Fetch ticekts on jira project using jql query
|
49
|
+
test_files: []
|