fastlane-plugin-jira_issues_release_notes 0.2.0 → 1.0.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.
@@ -3,15 +3,18 @@ require_relative '../helper/jira_issues_release_notes_helper'
3
3
 
4
4
  module Fastlane
5
5
  module Actions
6
- class BranchJiraIssuesReleaseNotesAction < Action
6
+ class JiraFeatureValidationAction < Action
7
7
  def self.run(params)
8
8
  branch = other_action.git_branch
9
- regex = Regexp.new("(#{params[:ticket_prefix]}-\\d+)")
9
+ ticket_key = Helper::JiraIssuesReleaseNotesHelper.extract_key_from_branch(
10
+ branch: branch,
11
+ ticket_prefix: params[:ticket_prefix]
12
+ )
10
13
 
11
14
  @format = params[:format]
12
15
  @extra_fields = params[:extra_fields]
16
+ @format_line_break = @format === 'html' ? '<br />' : "\n"
13
17
 
14
- ticket_code = regex.match branch
15
18
 
16
19
  return ticket_not_found unless ticket_code
17
20
 
@@ -20,6 +23,7 @@ module Fastlane
20
23
 
21
24
  @jira_helper = Helper::JiraIssuesReleaseNotesHelper.jira_helper(
22
25
  host: params[:host],
26
+ api_version: params[:api_version],
23
27
  username: params[:username],
24
28
  password: params[:password],
25
29
  context_path: params[:context_path],
@@ -31,34 +35,6 @@ module Fastlane
31
35
  return ticket_not_found ticket_code unless issue
32
36
 
33
37
  generate_message_with(issue: issue)
34
-
35
- # tickets = tickets(commits: commits, regex: regex)
36
- # UI.important("Jira tickets: #{tickets}")
37
-
38
- # @jira_helper = Helper::JiraIssuesReleaseNotesHelper.jira_helper(
39
- # host: params[:host],
40
- # username: params[:username],
41
- # password: params[:password],
42
- # context_path: params[:context_path],
43
- # disable_ssl_verification: params[:disable_ssl_verification]
44
- # )
45
- # issues = @jira_helper.get(issues: tickets)
46
-
47
- # to_validate = issues.select { |issue| params[:to_validate_status].include?(issue.status.name) }
48
- # validated = issues.select { |issue| params[:validated_status].include?(issue.status.name) }
49
-
50
- # generate_changelog(to_validate: to_validate, validated: validated, format: params[:format], url: params[:build_url])
51
- # end
52
-
53
- # def self.generate_changelog(to_validate:, validated:, format:, url:)
54
- # changelog = []
55
- # changelog.concat(format_issues(label: 'Tasks to validate', issues: to_validate, format: format)) unless to_validate.empty?
56
- # changelog.concat(['']) unless changelog.to_s.empty?
57
- # changelog.concat(format_issues(label: 'Validated tasks', issues: validated, format: format)) unless validated.empty?
58
- # # changes = format_issues(issues: issues)
59
- # changelog = ['No changes included.'] if changelog.to_s.empty?
60
-
61
- # changelog.join("\n")
62
38
  end
63
39
 
64
40
  def self.ticket_not_found(ticket_code = "")
@@ -70,48 +46,12 @@ module Fastlane
70
46
  header_text = ticket_code ? "😅 Jira issue with key '#{ticket_code}' could not be found" : "😅 Jira issue could not be detected"
71
47
 
72
48
  return [
73
- style_text(text: header_text, style: 'heading'),
74
- style_text(text: "► Latest Commit:", style: 'bold'),
49
+ Helper::JiraIssuesReleaseNotesHelper.style_text(text: header_text, style: 'heading'),
50
+ Helper::JiraIssuesReleaseNotesHelper.style_text(text: "► Latest Commit:", style: 'bold'),
75
51
  last_commit[:message]
76
52
  ].join("\n")
77
53
  end
78
-
79
- def self.style_text(text:, style:)
80
- # formats the text according to the style we're looking to use
81
-
82
- # Skips all styling
83
- case style
84
- when "title"
85
- case @format
86
- when "markdown"
87
- "# #{text}"
88
- when "slack"
89
- "*#{text}*"
90
- else
91
- text
92
- end
93
- when "heading"
94
- case format
95
- when "markdown"
96
- "### #{text}"
97
- when "slack"
98
- "*#{text}*"
99
- else
100
- "#{text}:"
101
- end
102
- when "bold"
103
- case format
104
- when "markdown"
105
- "**#{text}**"
106
- when "slack"
107
- "*#{text}*"
108
- else
109
- text
110
- end
111
- else
112
- text # catchall, shouldn't be needed
113
- end
114
- end
54
+
115
55
 
116
56
  def self.generate_message_with(issue:)
117
57
  link = @jira_helper.url(issue: issue)
@@ -127,7 +67,7 @@ module Fastlane
127
67
  extra.flatten!
128
68
  ]
129
69
  .flatten!
130
- .join("\n")
70
+ .join(@format_line_break)
131
71
  when "markdown"
132
72
  extra = @extra_fields.map { |key, value| ["", "**► #{key.to_s}**", issue.attrs["fields"][value.to_s]] }
133
73
  [
@@ -136,7 +76,16 @@ module Fastlane
136
76
  extra.flatten!
137
77
  ]
138
78
  .flatten!
139
- .join("\n")
79
+ .join(@format_line_break)
80
+ when "html"
81
+ extra = @extra_fields.map { |key, value| ["", "<strong>&#9658; #{key.to_s}</strong>", issue.attrs["fields"][value.to_s]] }
82
+ [
83
+ "<strong>&#9658; #{issue_type}: <a href=\"#{link}\" target=\"_blank\">#{issue.summary}</a></strong> (#{status})",
84
+ issue.description,
85
+ extra.flatten!
86
+ ]
87
+ .flatten!
88
+ .join(@format_line_break)
140
89
  else
141
90
  extra = @extra_fields.map { |key, value| ["", "► #{key.to_s}", issue.attrs["fields"][value.to_s]] }
142
91
  [
@@ -145,7 +94,7 @@ module Fastlane
145
94
  extra.flatten!
146
95
  ]
147
96
  .flatten!
148
- .join("\n")
97
+ .join(@format_line_break)
149
98
  end
150
99
  end
151
100
 
@@ -175,20 +124,13 @@ module Fastlane
175
124
  default_value: '[A-Z]+',
176
125
  optional: true
177
126
  ),
178
- FastlaneCore::ConfigItem.new(
179
- key: :build_url,
180
- env_name: 'FL_RELEASE_NOTES_BUILD_URL',
181
- description: 'Link to the ci build',
182
- optional: true,
183
- default_value: ENV['BUILD_URL']
184
- ),
185
127
  FastlaneCore::ConfigItem.new(
186
128
  key: :format,
187
- description: "You can use either markdown, slack or plain",
129
+ description: "You can use either markdown, slack, html or plain",
188
130
  default_value: "markdown",
189
131
  optional: true,
190
132
  verify_block: proc do |value|
191
- UI.user_error!("Invalid format! You can use either markdown, slack or plain") unless ['markdown', 'slack', 'plain'].include?(value)
133
+ UI.user_error!("Invalid format! You can use either markdown, slack, html or plain") unless ['markdown', 'html', 'slack', 'plain'].include?(value)
192
134
  end
193
135
  ),
194
136
  FastlaneCore::ConfigItem.new(
@@ -218,6 +160,13 @@ module Fastlane
218
160
  description: 'Jira location',
219
161
  optional: false
220
162
  ),
163
+ FastlaneCore::ConfigItem.new(
164
+ key: :api_version,
165
+ env_name: 'FL_JIRA_API_VERSION',
166
+ description: 'Jira api version',
167
+ default_value: '2',
168
+ optional: true,
169
+ ),
221
170
  FastlaneCore::ConfigItem.new(
222
171
  key: :context_path,
223
172
  env_name: 'FL_JIRA_CONTEXT_PATH',
@@ -0,0 +1,134 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/jira_issues_release_notes_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ module SharedValues
7
+ FL_JIRA_LAST_TAG ||= :S3_APK_OUTPUT_PATH
8
+ FL_JIRA_LAST_TAG_HASH ||= :FL_JIRA_LAST_TAG_HASH
9
+ FL_JIRA_COMMITS_FROM_HASH ||= :FL_JIRA_COMMITS_FROM_HASH
10
+ FL_JIRA_LAST_KEYS_FROM_COMMITS ||= :FL_JIRA_LAST_KEYS_FROM_COMMITS
11
+ FL_JIRA_LAST_ISSUES_FROM_COMMITS ||= :FL_JIRA_LAST_ISSUES_FROM_COMMITS
12
+ end
13
+
14
+ class JiraIssuesKeysFromCommitsAction < Action
15
+ def self.run(params)
16
+ Helper::JiraIssuesReleaseNotesHelper.initialize_jira(
17
+ host: params[:host],
18
+ api_version: params[:api_version],
19
+ username: params[:username],
20
+ password: params[:password],
21
+ context_path: params[:context_path],
22
+ disable_ssl_verification: params[:disable_ssl_verification]
23
+ )
24
+
25
+ issue_key_regex = Regexp.new("(#{params[:ticket_prefix]}-\\d+)")
26
+
27
+ Helper::JiraIssuesReleaseNotesHelper.get_keys_from_commit_after_latest_tag(
28
+ tag_regex: params[:tag_prefix],
29
+ tag_version_match: params[:tag_version_match],
30
+ issue_key_regex: issue_key_regex,
31
+ debug: params[:debug]
32
+ )
33
+ end
34
+
35
+ def self.description
36
+ "It generates a release note based on the issues keys found in branch name and descriptions found in the commits"
37
+ end
38
+
39
+ def self.authors
40
+ ["Erick Martins"]
41
+ end
42
+
43
+ def self.return_value
44
+ ["ABC-123", "ABC-321"]
45
+ end
46
+
47
+ def self.details
48
+ # Optional:
49
+ "It generates a release note based on the issues keys found in branch name and descriptions found in the commits"
50
+ end
51
+
52
+ def self.available_options
53
+ [
54
+ FastlaneCore::ConfigItem.new(
55
+ key: :tag_prefix,
56
+ description: "Match parameter of git describe. See man page of git describe for more info",
57
+ verify_block: proc do |value|
58
+ UI.user_error!("No match for analyze_commits action given, pass using `match: 'expr'`") unless value && !value.empty?
59
+ end
60
+ ),
61
+ FastlaneCore::ConfigItem.new(
62
+ key: :ticket_prefix,
63
+ env_name: 'FL_FIND_TICKETS_MATCHING',
64
+ description: 'regex to extract ticket numbers',
65
+ default_value: '[A-Z]+',
66
+ optional: true
67
+ ),
68
+ FastlaneCore::ConfigItem.new(
69
+ key: :tag_version_match,
70
+ description: "To parse version number from tag name",
71
+ default_value: '\d+\.\d+\.\d+'
72
+ ),
73
+
74
+ # Jira Client options
75
+ FastlaneCore::ConfigItem.new(
76
+ key: :username,
77
+ env_name: 'FL_JIRA_USERNAME',
78
+ description: 'Jira user',
79
+ optional: false
80
+ ),
81
+ FastlaneCore::ConfigItem.new(
82
+ key: :password,
83
+ env_name: 'FL_JIRA_PASSWORD',
84
+ description: 'Jira user',
85
+ optional: false
86
+ ),
87
+ FastlaneCore::ConfigItem.new(
88
+ key: :host,
89
+ env_name: 'FL_JIRA_HOST',
90
+ description: 'Jira location',
91
+ optional: false
92
+ ),
93
+ FastlaneCore::ConfigItem.new(
94
+ key: :api_version,
95
+ env_name: 'FL_JIRA_API_VERSION',
96
+ description: 'Jira api version',
97
+ default_value: '2',
98
+ optional: true,
99
+ ),
100
+ FastlaneCore::ConfigItem.new(
101
+ key: :context_path,
102
+ env_name: 'FL_JIRA_CONTEXT_PATH',
103
+ description: 'Jira context path',
104
+ optional: true,
105
+ default_value: ''
106
+ ),
107
+ FastlaneCore::ConfigItem.new(
108
+ key: :disable_ssl_verification,
109
+ env_name: 'FL_JIRA_DISABLE_SSL_VERIFICATION',
110
+ description: 'Jira SSL Verification mode',
111
+ optional: true,
112
+ default_value: false,
113
+ type: Boolean
114
+ ),
115
+ FastlaneCore::ConfigItem.new(
116
+ key: :debug,
117
+ description: "True if you want to log out a debug info",
118
+ default_value: false,
119
+ type: Boolean,
120
+ optional: true
121
+ )
122
+ ]
123
+ end
124
+
125
+ def self.is_supported?(platform)
126
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
127
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
128
+ #
129
+ # [:ios, :mac, :android].include?(platform)
130
+ true
131
+ end
132
+ end
133
+ end
134
+ end
@@ -0,0 +1,182 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/jira_issues_release_notes_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+
7
+ module SharedValues
8
+ FL_JIRA_LAST_TAG ||= :S3_APK_OUTPUT_PATH
9
+ FL_JIRA_LAST_TAG_HASH ||= :FL_JIRA_LAST_TAG_HASH
10
+ FL_JIRA_COMMITS_FROM_HASH ||= :FL_JIRA_COMMITS_FROM_HASH
11
+ FL_JIRA_LAST_KEYS_FROM_COMMITS ||= :FL_JIRA_LAST_KEYS_FROM_COMMITS
12
+ FL_JIRA_LAST_ISSUES_FROM_COMMITS ||= :FL_JIRA_LAST_ISSUES_FROM_COMMITS
13
+ end
14
+
15
+ class JiraReleaseChangelogAction < Action
16
+ def self.run(params)
17
+ Helper::JiraIssuesReleaseNotesHelper.initialize_jira(
18
+ host: params[:host],
19
+ api_version: params[:api_version],
20
+ username: params[:username],
21
+ password: params[:password],
22
+ context_path: params[:context_path],
23
+ disable_ssl_verification: params[:disable_ssl_verification]
24
+ )
25
+
26
+ issue_key_regex = Regexp.new("(#{params[:ticket_prefix]}-\\d+)")
27
+
28
+ issues = Helper::JiraIssuesReleaseNotesHelper.get_issues_from_commit_after_latest_tag(
29
+ tag_regex: params[:tag_prefix],
30
+ tag_version_match: params[:tag_version_match],
31
+ issue_key_regex: issue_key_regex,
32
+ debug: params[:debug]
33
+ )
34
+
35
+ return '' unless issues
36
+
37
+ @format = params[:format]
38
+ @format_line_break = @format === 'html' ? '<br />' : "\n"
39
+
40
+ grouped_by_types = params[:grouped_by_types]
41
+
42
+ grouped_issues = {}
43
+
44
+ group_key_for_any = nil
45
+
46
+ grouped_by_types.each do |key, value|
47
+ matched_issues = issues.filter {|issue| value.include?(issue.issuetype.name) }
48
+ not_matched_issues = issues.filter {|issue| !value.include?(issue.issuetype.name) }
49
+
50
+ grouped_issues[key] = matched_issues
51
+
52
+ issues = not_matched_issues
53
+
54
+ group_key_for_any = key if value.include? "ANY_TYPE"
55
+ end
56
+
57
+ if group_key_for_any and issues then
58
+ grouped_issues[group_key_for_any].concat issues
59
+ end
60
+
61
+ Helper::JiraIssuesReleaseNotesHelper.generate_changelog(
62
+ groups: grouped_issues,
63
+ line_break_format: @format_line_break
64
+ )
65
+ end
66
+
67
+ def self.description
68
+ "It generates a release note based on the issues keys and descriptions found in the commits"
69
+ end
70
+
71
+ def self.authors
72
+ ["Erick Martins"]
73
+ end
74
+
75
+ def self.return_value
76
+ # If your method provides a return value, you can describe here what it does
77
+ end
78
+
79
+ def self.details
80
+ # Optional:
81
+ "It generates a release note based on the issues keys and descriptions found in the commits"
82
+ end
83
+
84
+ def self.available_options
85
+ [
86
+ FastlaneCore::ConfigItem.new(
87
+ key: :tag_prefix,
88
+ description: "Match parameter of git describe. See man page of git describe for more info",
89
+ verify_block: proc do |value|
90
+ UI.user_error!("No match for analyze_commits action given, pass using `match: 'expr'`") unless value && !value.empty?
91
+ end
92
+ ),
93
+ FastlaneCore::ConfigItem.new(
94
+ key: :ticket_prefix,
95
+ env_name: 'FL_FIND_TICKETS_MATCHING',
96
+ description: 'regex to extract ticket numbers',
97
+ default_value: '[A-Z]+',
98
+ optional: true
99
+ ),
100
+ FastlaneCore::ConfigItem.new(
101
+ key: :tag_version_match,
102
+ description: "To parse version number from tag name",
103
+ default_value: '\d+\.\d+\.\d+'
104
+ ),
105
+ FastlaneCore::ConfigItem.new(
106
+ key: :grouped_by_types,
107
+ env_name: 'FL_JIRA_RELESE_GROUPED_TYPES',
108
+ description: 'Hash with grouped types with names by issue type. Use de key work "ANY_TYPE" as fallback. Example: { "Fixed" => ["Bug"], "Added/Changed" => ["Story", "Task"], "Others" => ["ANY_TYPE"] } ',
109
+ optional: false,
110
+ type: Hash
111
+ ),
112
+ FastlaneCore::ConfigItem.new(
113
+ key: :format,
114
+ description: "You can use either markdown, slack, html or plain",
115
+ default_value: "markdown",
116
+ optional: true,
117
+ verify_block: proc do |value|
118
+ UI.user_error!("Invalid format! You can use either markdown, slack, html or plain") unless ['markdown', 'html', 'slack', 'plain'].include?(value)
119
+ end
120
+ ),
121
+
122
+ # Jira Client options
123
+ FastlaneCore::ConfigItem.new(
124
+ key: :username,
125
+ env_name: 'FL_JIRA_USERNAME',
126
+ description: 'Jira user',
127
+ optional: false
128
+ ),
129
+ FastlaneCore::ConfigItem.new(
130
+ key: :password,
131
+ env_name: 'FL_JIRA_PASSWORD',
132
+ description: 'Jira user password',
133
+ optional: false
134
+ ),
135
+ FastlaneCore::ConfigItem.new(
136
+ key: :host,
137
+ env_name: 'FL_JIRA_HOST',
138
+ description: 'Jira location',
139
+ optional: false
140
+ ),
141
+ FastlaneCore::ConfigItem.new(
142
+ key: :api_version,
143
+ env_name: 'FL_JIRA_API_VERSION',
144
+ description: 'Jira api version',
145
+ default_value: '2',
146
+ optional: true,
147
+ ),
148
+ FastlaneCore::ConfigItem.new(
149
+ key: :context_path,
150
+ env_name: 'FL_JIRA_CONTEXT_PATH',
151
+ description: 'Jira context path',
152
+ optional: true,
153
+ default_value: ''
154
+ ),
155
+ FastlaneCore::ConfigItem.new(
156
+ key: :disable_ssl_verification,
157
+ env_name: 'FL_JIRA_DISABLE_SSL_VERIFICATION',
158
+ description: 'Jira SSL Verification mode',
159
+ optional: true,
160
+ default_value: false,
161
+ type: Boolean
162
+ ),
163
+ FastlaneCore::ConfigItem.new(
164
+ key: :debug,
165
+ description: "True if you want to log out a debug info",
166
+ default_value: false,
167
+ type: Boolean,
168
+ optional: true
169
+ )
170
+ ]
171
+ end
172
+
173
+ def self.is_supported?(platform)
174
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
175
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
176
+ #
177
+ # [:ios, :mac, :android].include?(platform)
178
+ true
179
+ end
180
+ end
181
+ end
182
+ end