fastlane-plugin-jira_issues_release_notes 0.4.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,16 +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]
13
16
  @format_line_break = @format === 'html' ? '<br />' : "\n"
14
17
 
15
- ticket_code = regex.match branch
16
18
 
17
19
  return ticket_not_found unless ticket_code
18
20
 
@@ -21,6 +23,7 @@ module Fastlane
21
23
 
22
24
  @jira_helper = Helper::JiraIssuesReleaseNotesHelper.jira_helper(
23
25
  host: params[:host],
26
+ api_version: params[:api_version],
24
27
  username: params[:username],
25
28
  password: params[:password],
26
29
  context_path: params[:context_path],
@@ -43,53 +46,12 @@ module Fastlane
43
46
  header_text = ticket_code ? "😅 Jira issue with key '#{ticket_code}' could not be found" : "😅 Jira issue could not be detected"
44
47
 
45
48
  return [
46
- style_text(text: header_text, style: 'heading'),
47
- 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'),
48
51
  last_commit[:message]
49
52
  ].join("\n")
50
53
  end
51
- def self.style_text(text:, style:)
52
- # formats the text according to the style we're looking to use
53
-
54
- # Skips all styling
55
- case style
56
- when "title"
57
- case @format
58
- when "markdown"
59
- "# #{text}"
60
- when "slack"
61
- "*#{text}*"
62
- when "html"
63
- "<h1>#{text}</h1>"
64
- else
65
- text
66
- end
67
- when "heading"
68
- case @format
69
- when "markdown"
70
- "### #{text}"
71
- when "slack"
72
- "*#{text}*"
73
- when "html"
74
- "<h3>#{text}</h3>"
75
- else
76
- "#{text}:"
77
- end
78
- when "bold"
79
- case @format
80
- when "markdown"
81
- "**#{text}**"
82
- when "slack"
83
- "*#{text}*"
84
- when "html"
85
- "<strong>#{text}</strong>"
86
- else
87
- text
88
- end
89
- else
90
- text # catchall, shouldn't be needed
91
- end
92
- end
54
+
93
55
 
94
56
  def self.generate_message_with(issue:)
95
57
  link = @jira_helper.url(issue: issue)
@@ -198,6 +160,13 @@ module Fastlane
198
160
  description: 'Jira location',
199
161
  optional: false
200
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
+ ),
201
170
  FastlaneCore::ConfigItem.new(
202
171
  key: :context_path,
203
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
@@ -0,0 +1,173 @@
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 JiraReleaseValidationAction < Action
16
+ def self.run(params)
17
+ Helper::JiraIssuesReleaseNotesHelper.initialize_jira(
18
+ host: params[:host],
19
+ username: params[:username],
20
+ password: params[:password],
21
+ context_path: params[:context_path],
22
+ api_version: params[:api_version],
23
+ disable_ssl_verification: params[:disable_ssl_verification]
24
+ )
25
+
26
+ @format = params[:format]
27
+ @format_line_break = @format === 'html' ? '<br />' : "\n"
28
+
29
+ issue_key_regex = Regexp.new("(#{params[:ticket_prefix]}-\\d+)")
30
+
31
+ issues = Helper::JiraIssuesReleaseNotesHelper.get_issues_from_commit_after_latest_tag(
32
+ tag_regex: params[:tag_prefix],
33
+ tag_version_match: params[:tag_version_match],
34
+ issue_key_regex: issue_key_regex,
35
+ debug: params[:debug]
36
+ )
37
+
38
+ return '' unless issues
39
+
40
+ grouped_issues = {
41
+ "Tasks to validate" => issues.select { |issue| params[:to_validate_status].include?(issue.status.name) },
42
+ "Validated tasks" => issues.select { |issue| params[:validated_status].include?(issue.status.name) }
43
+ }
44
+
45
+ Helper::JiraIssuesReleaseNotesHelper.generate_changelog(
46
+ groups: grouped_issues,
47
+ line_break_format: @format_line_break
48
+ )
49
+ end
50
+
51
+ def self.description
52
+ "It generates a release note based on the issues keys and descriptions found in the commits"
53
+ end
54
+
55
+ def self.authors
56
+ ["Erick Martins"]
57
+ end
58
+
59
+ def self.return_value
60
+ # If your method provides a return value, you can describe here what it does
61
+ end
62
+
63
+ def self.details
64
+ # Optional:
65
+ "It generates a release note based on the issues keys and descriptions found in the commits"
66
+ end
67
+
68
+ def self.available_options
69
+ [
70
+ FastlaneCore::ConfigItem.new(
71
+ key: :tag_prefix,
72
+ description: "Match parameter of git describe. See man page of git describe for more info",
73
+ verify_block: proc do |value|
74
+ UI.user_error!("No match for analyze_commits action given, pass using `match: 'expr'`") unless value && !value.empty?
75
+ end
76
+ ),
77
+ FastlaneCore::ConfigItem.new(
78
+ key: :ticket_prefix,
79
+ env_name: 'FL_FIND_TICKETS_MATCHING',
80
+ description: 'regex to extract ticket numbers',
81
+ default_value: '[A-Z]+',
82
+ optional: true
83
+ ),
84
+ FastlaneCore::ConfigItem.new(
85
+ key: :tag_version_match,
86
+ description: "To parse version number from tag name",
87
+ default_value: '\d+\.\d+\.\d+'
88
+ ),
89
+ FastlaneCore::ConfigItem.new(
90
+ key: :validated_status,
91
+ env_name: 'FL_JIRA_VALIDATED_STATUS',
92
+ description: 'List of jira issues status already validated',
93
+ optional: false,
94
+ type: Array
95
+ ),
96
+ FastlaneCore::ConfigItem.new(
97
+ key: :to_validate_status,
98
+ env_name: 'FL_JIRA_TO_VALIDATE_STATUS',
99
+ description: 'List of jira issues status to be validated',
100
+ optional: false,
101
+ type: Array
102
+ ),
103
+ FastlaneCore::ConfigItem.new(
104
+ key: :format,
105
+ description: "You can use either markdown, slack, html or plain",
106
+ default_value: "markdown",
107
+ optional: true,
108
+ verify_block: proc do |value|
109
+ UI.user_error!("Invalid format! You can use either markdown, slack, html or plain") unless ['markdown', 'html', 'slack', 'plain'].include?(value)
110
+ end
111
+ ),
112
+
113
+ # Jira Client options
114
+ FastlaneCore::ConfigItem.new(
115
+ key: :username,
116
+ env_name: 'FL_JIRA_USERNAME',
117
+ description: 'Jira user',
118
+ optional: false
119
+ ),
120
+ FastlaneCore::ConfigItem.new(
121
+ key: :password,
122
+ env_name: 'FL_JIRA_PASSWORD',
123
+ description: 'Jira user password',
124
+ optional: false
125
+ ),
126
+ FastlaneCore::ConfigItem.new(
127
+ key: :host,
128
+ env_name: 'FL_JIRA_HOST',
129
+ description: 'Jira location',
130
+ optional: false
131
+ ),
132
+ FastlaneCore::ConfigItem.new(
133
+ key: :api_version,
134
+ env_name: 'FL_JIRA_API_VERSION',
135
+ description: 'Jira api version',
136
+ default_value: '2',
137
+ optional: true,
138
+ ),
139
+ FastlaneCore::ConfigItem.new(
140
+ key: :context_path,
141
+ env_name: 'FL_JIRA_CONTEXT_PATH',
142
+ description: 'Jira context path',
143
+ optional: true,
144
+ default_value: ''
145
+ ),
146
+ FastlaneCore::ConfigItem.new(
147
+ key: :disable_ssl_verification,
148
+ env_name: 'FL_JIRA_DISABLE_SSL_VERIFICATION',
149
+ description: 'Jira SSL Verification mode',
150
+ optional: true,
151
+ default_value: false,
152
+ type: Boolean
153
+ ),
154
+ FastlaneCore::ConfigItem.new(
155
+ key: :debug,
156
+ description: "True if you want to log out a debug info",
157
+ default_value: false,
158
+ type: Boolean,
159
+ optional: true
160
+ )
161
+ ]
162
+ end
163
+
164
+ def self.is_supported?(platform)
165
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
166
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
167
+ #
168
+ # [:ios, :mac, :android].include?(platform)
169
+ true
170
+ end
171
+ end
172
+ end
173
+ end