fastlane-plugin-jira_issue_details 0.1.0 → 0.2.0

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: 4c593c03b31741d49f1c77b778fc9e9092ad1539
4
- data.tar.gz: 985a286d908052bba6a57fd4deae1697d3dc5cd2
3
+ metadata.gz: f8e4e65b0e2830cb2cd5529f0684100505cd46ed
4
+ data.tar.gz: 8ec1259b484de24c4e2da3158ec0c0f7cb4632e4
5
5
  SHA512:
6
- metadata.gz: 7414de5d77f9321fbc1e7cc5238e55f24d2c7bec8d8f54dc0ae2dfdef99db8fa116f79b49c4a3b7b6bea3b376fc25e31b9fe76e5a3a4f319ea56a6ef0ad2b9cf
7
- data.tar.gz: 37b631d0467f15b9a1605647288d44f19545ca2afdaabdd11970ae9e6102af252e282ad97463697061b2fefa8dba6cf870892bfd0f6d71050fdc38f8118bd092
6
+ metadata.gz: 446fc9d66a571582a1b9464dae93e7e4267b2c5c5798467172d3c5d94f73466bbe92e0ed7a73510eb0fcb3fdd390752b2bdbdb706abecbc98ed4bafd7ec75ee2
7
+ data.tar.gz: 6283b7eff344c8b3a69428a82e8f3443ac1c38b15eb0638dabaf614650c8e9b3e579fc02a57f99341b9d5d646db6e422f40fb8e8c48cc005a06c9f7cab50bdff
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Jira Issue Details `fastlane` Plugin [![Build Status](https://app.bitrise.io/app/72df6f31dbaba55c/status.svg?token=eNywJtIKO1opSsI9PbEHVQ&branch=develop)](https://app.bitrise.io/app/72df6f31dbaba55c)
2
2
 
3
- [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-jira_issue_details)
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-jira_issue_details) [![Gem Version](https://badge.fury.io/rb/fastlane-plugin-jira_issue_details.svg)](https://badge.fury.io/rb/fastlane-plugin-jira_issue_details)
4
4
 
5
5
  ## Getting Started
6
6
 
@@ -26,17 +26,44 @@ Get the jira issue by passing the `username`, `api_token`, `site` and `issue_key
26
26
 
27
27
  Do note that all parameters are required, otherwise the action will return `nil`.
28
28
 
29
- ```ruby
30
- issue = get_jira_issue(
31
- username: 'you@domain.com',
32
- api_token: 'yourapitoken',
33
- site: 'https://your-domain.atlassian.net',
34
- issue_key: 'TCK-123'
35
- )
36
- summary = issue['fields']['summary']
37
- puts summary
38
- #=> Short summary for the ticket id: TCK-123.
39
- ```
29
+ 1. Passing a single jira `issue_key`
30
+
31
+ In return, you'll get a single hash, or `nil` if the issue for the given key was not found.
32
+
33
+ ```ruby
34
+ issue = get_jira_issue(
35
+ username: 'you@domain.com',
36
+ api_token: 'yourapitoken',
37
+ site: 'https://your-domain.atlassian.net',
38
+ issue_key: 'TKT-123'
39
+ )
40
+
41
+ summary = issue['fields']['summary']
42
+ puts summary
43
+ #=> Short summary for the ticket id TKT-123
44
+ ```
45
+
46
+ 1. Passing multiple jira `issue_key`s (Do note that you should **only** separate the keys using a single space ` `)
47
+
48
+ In return, you'll get a hash of `key-hash` pair, or `key-nil` pair if the issue was not found.
49
+
50
+ ```ruby
51
+ issue = get_jira_issue(
52
+ username: 'you@domain.com',
53
+ api_token: 'yourapitoken',
54
+ site: 'https://your-domain.atlassian.net',
55
+ issue_key: 'TKT-123 TKT-456'
56
+ )
57
+
58
+ summary = issue['TKT-123']['fields']['summary']
59
+ puts summary
60
+ #=> Short summary for the ticket id: TKT-123
61
+
62
+ # assuming TKT-456 doesn't exist
63
+ summary = issue['TKT-456']
64
+ puts summary
65
+ #=> nil
66
+ ```
40
67
 
41
68
  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`.
42
69
 
@@ -6,39 +6,16 @@ module Fastlane
6
6
  module Actions
7
7
  class GetJiraIssueAction < Action
8
8
  def self.run(params)
9
- site = ENV['JIRA_ISSUE_DETAILS_SITE']
10
- username = ENV['JIRA_ISSUE_DETAILS_USERNAME']
11
- api_token = ENV['JIRA_ISSUE_DETAILS_API_TOKEN']
12
- issue_key = ENV['JIRA_ISSUE_DETAILS_ISSUE_KEY']
13
-
14
- if params && params[:site] && params[:username] && params[:api_token] && params[:issue_key]
15
- site = params[:site]
16
- username = params[:username]
17
- api_token = params[:api_token]
18
- issue_key = params[:issue_key]
19
- end
20
-
21
- return nil if site.nil? && username.nil? && api_token.nil? && issue_key.nil?
22
-
23
- options = {
24
- username: username,
25
- password: api_token,
26
- context_path: "",
27
- auth_type: :basic,
28
- site: "#{site}:443/",
29
- rest_base_path: "/rest/api/3"
30
- }
31
- client = JIRA::Client.new(options)
9
+ input = get_input_from_env
10
+ input = get_input_from(params) if is_exists?(params)
11
+ return nil if is_nil_any(input)
32
12
 
33
- begin
34
- return client.Issue.find(issue_key).attrs
35
- rescue
36
- return nil
37
- end
13
+ client = JIRA::Client.new(options_for_jira_client(input))
14
+ return get_issues_from(client, input)
38
15
  end
39
16
 
40
17
  def self.description
41
- "Get the details for the given jira issue key."
18
+ "Get the details for the given jira issue key(s)."
42
19
  end
43
20
 
44
21
  def self.authors
@@ -46,11 +23,14 @@ module Fastlane
46
23
  end
47
24
 
48
25
  def self.return_value
49
- "Return a `Hash` containing the details of the jira issue for the given key, or `nil` if the issue key does not exists."
26
+ single_key = "it returns a `Hash` containing the details of the jira issue for the given key, or `nil` if the issue key does not exists."
27
+ multiple_key = "it returns a `Hash` of `key-Hash` pairs containing the details of the jira issue key, or `key-nil` pair if the issue key does not exists."
28
+
29
+ "For single jira issue key, #{single_key} For multiple jira issue keys, #{multiple_key}"
50
30
  end
51
31
 
52
32
  def self.details
53
- "It utilises the `jira-ruby` gem to communicate with Jira and get the details of the Jira issue for the given key.\n\n(Currently only supports basic auth_type login)"
33
+ "It utilises the `jira-ruby` gem to communicate with Jira and get the details of the Jira issue for the given key.\n\n(Currently only supports basic auth_type login)."
54
34
  end
55
35
 
56
36
  def self.available_options
@@ -75,7 +55,7 @@ module Fastlane
75
55
 
76
56
  FastlaneCore::ConfigItem.new(key: :issue_key,
77
57
  env_name: "JIRA_ISSUE_DETAILS_ISSUE_KEY",
78
- description: "Your Jira Issue Key",
58
+ description: "Your Jira Issue Key(s). Separate with a single space ` ` to add more keys",
79
59
  optional: false,
80
60
  type: String)
81
61
  ]
@@ -84,6 +64,62 @@ module Fastlane
84
64
  def self.is_supported?(platform)
85
65
  true
86
66
  end
67
+
68
+ private
69
+
70
+ def self.get_input_from_env
71
+ {
72
+ site: ENV['JIRA_ISSUE_DETAILS_SITE'],
73
+ username: ENV['JIRA_ISSUE_DETAILS_USERNAME'],
74
+ api_token: ENV['JIRA_ISSUE_DETAILS_API_TOKEN'],
75
+ issue_key: ENV['JIRA_ISSUE_DETAILS_ISSUE_KEY']
76
+ }
77
+ end
78
+
79
+ def self.is_exists?(params)
80
+ params && params[:site] && params[:username] && params[:api_token] && params[:issue_key]
81
+ end
82
+
83
+ def self.get_input_from(params)
84
+ {
85
+ site: params[:site],
86
+ username: params[:username],
87
+ api_token: params[:api_token],
88
+ issue_key: params[:issue_key]
89
+ }
90
+ end
91
+
92
+ def self.is_nil_any(input)
93
+ input[:site].nil? || input[:username].nil? || input[:api_token].nil? || input[:issue_key].nil?
94
+ end
95
+
96
+ def self.options_for_jira_client(input)
97
+ {
98
+ username: input[:username],
99
+ password: input[:api_token],
100
+ context_path: "",
101
+ auth_type: :basic,
102
+ site: "#{input[:site]}:443/",
103
+ rest_base_path: "/rest/api/3"
104
+ }
105
+ end
106
+
107
+ def self.get_issues_from(client, input)
108
+ issues = {}
109
+ keys = input[:issue_key].split(" ")
110
+ keys.each {|key| issues[key] = fetch_issue(key, client) }
111
+
112
+ return issues[keys.first] if keys.count == 1
113
+ return issues
114
+ end
115
+
116
+ def self.fetch_issue(key, client)
117
+ begin
118
+ return client.Issue.find(key).attrs
119
+ rescue
120
+ return nil
121
+ end
122
+ end
87
123
  end
88
124
  end
89
125
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module JiraIssueDetails
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-jira_issue_details
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zaim Ramlan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-25 00:00:00.000000000 Z
11
+ date: 2018-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -136,6 +136,34 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: 2.108.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: jira-ruby
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '='
144
+ - !ruby/object:Gem::Version
145
+ version: 1.6.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '='
151
+ - !ruby/object:Gem::Version
152
+ version: 1.6.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: webmock
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '='
158
+ - !ruby/object:Gem::Version
159
+ version: 3.4.2
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '='
165
+ - !ruby/object:Gem::Version
166
+ version: 3.4.2
139
167
  description:
140
168
  email: zaimramlan@gmail.com
141
169
  executables: []
@@ -171,5 +199,5 @@ rubyforge_project:
171
199
  rubygems_version: 2.6.13
172
200
  signing_key:
173
201
  specification_version: 4
174
- summary: Get the details for the given jira issue key
202
+ summary: Get the details for the given jira issue key(s)
175
203
  test_files: []