fastlane-plugin-cerberus 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4384ba7a06799192ab423761428aebd7a184f4da
4
+ data.tar.gz: a35a36e207969e6bb02d68ff294cba41c48485a6
5
+ SHA512:
6
+ metadata.gz: b202049fd673336638c9393c60d6b85bb168710018050abaa1200a80b4669876e031c6180baf9246fd6523d496a4b5403874ddfb1030be6303d30f04237bb5ca
7
+ data.tar.gz: 7a061e61ef221aa0c3e5be3143fcbca561acfb5e8c789deaff85d2e04678e8028caca7181329ee39e42b70d2bbb09977c59e9585c3be1c6d92376d1f3f21429a
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Harry Singh <harry.singh@outware.com.au>
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.
@@ -0,0 +1,257 @@
1
+ # Cerberus
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-cerberus) [![CircleCI](https://circleci.com/gh/outware/fastlane-plugin-cerberus.svg?style=svg)](https://circleci.com/gh/outware/fastlane-plugin-cerberus)
4
+
5
+ * [Getting Started](#getting-started)
6
+ * [About](#about)
7
+ * [Integration Guide](#integration-guide)
8
+ * [Actions](#actions)
9
+ + [find_tickets](#find_tickets)
10
+ + [find_commits](#find_commits)
11
+ + [jira_comment](#jira_comment)
12
+ + [release_notes](#release_notes)
13
+ * [Example](#example)
14
+ * [Run tests for this plugin](#run-tests-for-this-plugin)
15
+ * [Issues and Feedback](#issues-and-feedback)
16
+ * [Troubleshooting](#troubleshooting)
17
+ * [Using _fastlane_ Plugins](#using-_fastlane_-plugins)
18
+ * [About _fastlane_](#about-_fastlane_)
19
+
20
+ ## Getting Started
21
+
22
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-cerberus`, add it to your project by running:
23
+
24
+ ```bash
25
+ fastlane add_plugin cerberus
26
+ ```
27
+
28
+ ## About
29
+
30
+ Cerberus is a fastlane plugin for extracting Jira issues from commit messages and sharing information on its respective Jenkins job and HockeyApp upload.
31
+
32
+ Using all of Cerberus' features, you can use your commit history -
33
+
34
+ ```
35
+ * HEAD -> Develop
36
+ | \
37
+ * \
38
+ | \ |
39
+ | | * [CER-12] Address PR Feedback
40
+ | | * [CER-12] Fix bug
41
+ | | |
42
+ | * | [CER-7] Add feature
43
+ | / |
44
+ ```
45
+
46
+ to generate release notes using data from Jira and your build -
47
+
48
+ ```
49
+ ### Changelog
50
+ - [CER-12] UI Bug
51
+ - [CER-7] Minor Feature
52
+
53
+ Built by [Jenkins](https://jenkins.url/build/451)
54
+ ```
55
+
56
+ and comment on your Jira tickets with build and artefact information
57
+
58
+ ```
59
+ Jenkins: [Build #451|https://jenkins.url/build/451]
60
+ HockeyApp: [Version 2.0-RC|https://hockey.url/app/d3adcaf3]
61
+ ```
62
+
63
+ ## Integration Guide
64
+
65
+ Please take a look at the project [integration guide](INTEGRATION.md) to get you started.
66
+
67
+ ## Actions
68
+
69
+ ### [find_tickets](lib/fastlane/plugin/cerberus/actions/find_tickets_action.rb)
70
+
71
+ This action will extract tickets using a provided regular expression. The default format is as follows:
72
+ `ABC-123`, one or more capital letters, followed by a dash, followed by one or more digits.
73
+
74
+ #### Parameters
75
+
76
+ | Parameter | Environment Name | Default Value | Description |
77
+ |----------- |------------------------------- |--------------------------------------------------- |------------------------------------------------------------------------------ |
78
+ | from | FL_FIND_TICKETS_FROM | `'HEAD'` | The commit SHA of the first commit to parse for ticket information. |
79
+ | to | FL_FIND_TICKETS_TO | `ENV[GIT_PREVIOUS_SUCCESSFUL_COMMIT]` or `'HEAD'` | The commit SHA of the last commit to parse for ticket information. |
80
+ | matching | FL_FIND_TICKETS_MATCHING | `'([A-Z]+-\d+)'` | Regex which will be used to extract the tickets from the commit messages. |
81
+ | excluding | FL_FIND_TICKETS_EXCLUDING | | Additional regex to ignore specific commits or keywords. |
82
+ | pretty | FL_FIND_TICKETS_PRETTY_FORMAT | `'* (%h) %s'` | [A git log pretty format.](https://git-scm.com/docs/git-log#_pretty_formats) |
83
+
84
+ #### Usage
85
+
86
+ ```ruby
87
+ find_tickets(
88
+ from: 'HEAD',
89
+ to: '81fae0ffcc714fb56a1c186ae7c73c80442fff74',
90
+ matching: '([A-Z]+-\d+)',
91
+ excluding: 'TECH',
92
+ pretty: '* (%h) %s'
93
+ )
94
+ ```
95
+
96
+ #### Result
97
+
98
+ Returns an Array of Strings. e.g `["CER-1", "CER-2"]`
99
+
100
+ ---
101
+
102
+ ### [find_commits](lib/fastlane/plugin/cerberus/actions/find_commits_action.rb)
103
+
104
+ Extracts the commit messages from a set of commits using regex.
105
+
106
+ #### Parameters
107
+
108
+ | Parameter | Environment Name | Default Value | Description |
109
+ |----------- |------------------------------- |---------------------------------------- |------------------------------------------------------------------------------ |
110
+ | from | FL_FIND_COMMITS_FROM | `ENV['FL_FIND_TICKETS_FROM']` | The commit SHA of the first commit to parse for ticket information. |
111
+ | to | FL_FIND_COMMITS_TO | `ENV['FL_FIND_TICKETS_TO']` | The commit SHA of the last commit to parse for ticket information. |
112
+ | matching | FL_FIND_COMMITS_MATCHING | `ENV['FL_FIND_TICKETS_MATCHING']` | Regex which will be used to extract the tickets from the commit messages. |
113
+ | pretty | FL_FIND_COMMITS_PRETTY_FORMAT | `ENV['FL_FIND_TICKETS_PRETTY_FORMAT']` | [A git log pretty format.](https://git-scm.com/docs/git-log#_pretty_formats) |
114
+
115
+ #### Usage
116
+
117
+ ```ruby
118
+ find_commits(
119
+ from: 'HEAD',
120
+ to: '81fae0ffcc714fb56a1c186ae7c73c80442fff74',
121
+ matching: 'TECH',
122
+ pretty: '%s'
123
+ )
124
+ ```
125
+
126
+ #### Result
127
+
128
+ Returns an Array of Strings. e.g `["[TECH] - Update SSL pinning"]`
129
+
130
+ ---
131
+
132
+ ### [jira_comment](lib/fastlane/plugin/cerberus/actions/jira_comment_action.rb)
133
+
134
+ Adds a comment on the Jira isses with the CI build number and the link to the CI build it also adds a link to the HockeyApp build and its build number.
135
+
136
+ #### Parameters
137
+
138
+ | Parameter | Environment Name | Default Value | Description |
139
+ |-------------------------- |---------------------------------- |------------------------------------------------------------ |----------------------------------------------------- |
140
+ | issues | FL_JIRA_COMMENT_ISSUES | `[]` | The Jira issues to comment on. An Array of Strings. |
141
+ | build_number | FL_JIRA_COMMENT_BUILD_NUMBER | `ENV['BUILD_NUMBER']` | The CI build number that built the current changes. |
142
+ | build_url | FL_JIRA_COMMENT_BUILD_URL | `ENV['BUILD_URL']` | URL to the CI build. |
143
+ | app_version | FL_JIRA_COMMENT_APP_VERSION | | The current app version. |
144
+ | hockey_url | FL_JIRA_COMMENT_HOCKEY_URL | `Actions.lane_context[SharedValues::HOCKEY_DOWNLOAD_LINK]` | URL to the HockeyApp build. |
145
+ | username | FL_JIRA_USERNAME | | Jira username. |
146
+ | password | FL_JIRA_PASSWORD | | Jira password. |
147
+ | host | FL_JIRA_HOST | | Jira host location. |
148
+ | context_path | FL_JIRA_CONTEXT_PATH | `''` | Jira context path. |
149
+ | disable_ssl_verification | FL_JIRA_DISABLE_SSL_VERIFICATION | `false` | Disable Jira SSL verification. |
150
+
151
+ #### Usage
152
+
153
+ ```ruby
154
+ jira_comment(
155
+ issues: ['CER-1', 'CER-2'],
156
+ build_number: '1',
157
+ build_url: 'https://www.jenkins.com/build/1',
158
+ app_version: '1.0-QA',
159
+ hockey_url: 'https://rink.hockeyapp.net/apps/32c5df727eac426',
160
+ username: 'jenkins',
161
+ password: 'XYZ123',
162
+ host: 'https://jira.com',
163
+ context_path: '',
164
+ disable_ssl_verification: false
165
+ )
166
+ ```
167
+
168
+ #### Result
169
+
170
+ Adds a comment on all the issues provided which have an accociated Jira issue in the following format:
171
+
172
+ ```
173
+ Jenkins: [Build ##{build_number}|#{build_url}]
174
+
175
+ HockeyApp: [Version #{app_version} (#{build_number})|#{hockey_url}]
176
+ ```
177
+
178
+ ---
179
+
180
+ ### [release_notes](lib/fastlane/plugin/cerberus/actions/release_notes_action.rb)
181
+
182
+ Generates a changelog containing all the completed issues and any additional messages to be included as part of the changelog. It sets the `FL_CHANGELOG` shared value with the changelog.
183
+
184
+ #### Parameters
185
+
186
+ | Parameter | Environment Name | Default Value | Description |
187
+ |-------------------------- |----------------------------------- |-------------------- |------------------------------------------------------------------------- |
188
+ | issues | FL_RELEASE_NOTES_ISSUES | `[]` | The Jira issues completed as part of this build. An Array of Strings. |
189
+ | include_commits | FL_HOCKEY_COMMENT_INCLUDE_COMMITS | `[]` | Additional commit messages to be included as part of the release notes. |
190
+ | build_url | FL_RELEASE_NOTES_BUILD_URL | `ENV['BUILD_URL']` | URL to the CI build. |
191
+ | username | FL_JIRA_USERNAME | | Jira username. |
192
+ | password | FL_JIRA_PASSWORD | | Jira password. |
193
+ | host | FL_JIRA_HOST | | Jira host location. |
194
+ | context_path | FL_JIRA_CONTEXT_PATH | `''` | Jira context path. |
195
+ | disable_ssl_verification | FL_JIRA_DISABLE_SSL_VERIFICATION | `false` | Disable Jira SSL verification. |
196
+
197
+ #### Usage
198
+
199
+ ```ruby
200
+ release_notes(
201
+ issues: ['CER-1', 'CER-2'],
202
+ include_commits: ["[TECH] - Add SSL"],
203
+ build_url: 'https://www.jenkins.com/build/1',
204
+ username: 'jenkins',
205
+ password: 'XYZ123',
206
+ host: 'https://jira.com',
207
+ context_path: '',
208
+ disable_ssl_verification: false
209
+ )
210
+ ```
211
+
212
+ #### Result
213
+
214
+ Returns a String containing all the changes and additional messages in the following `markdown` format:
215
+ ```
216
+ ### Changelog
217
+
218
+ - [CER-1](URL): Issue summary
219
+ - TECH: Additional commit message
220
+
221
+ Built by [Jenkins](URL)
222
+ ```
223
+
224
+ ---
225
+
226
+ ## Example
227
+
228
+ 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`.
229
+
230
+ ## Run tests for this plugin
231
+
232
+ To run both the tests, and code style validation, run
233
+
234
+ ```bash
235
+ rake
236
+ ```
237
+
238
+ To automatically fix many of the styling issues, use
239
+ ```bash
240
+ rubocop -a
241
+ ```
242
+
243
+ ## Issues and Feedback
244
+
245
+ For any other issues and feedback about this plugin, please submit it to this repository.
246
+
247
+ ## Troubleshooting
248
+
249
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
250
+
251
+ ## Using _fastlane_ Plugins
252
+
253
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
254
+
255
+ ## About _fastlane_
256
+
257
+ _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,16 @@
1
+ require 'fastlane/plugin/cerberus/version'
2
+
3
+ module Fastlane
4
+ module Cerberus
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::Cerberus.all_classes.each do |current|
15
+ require current
16
+ end
@@ -0,0 +1,100 @@
1
+ module Fastlane
2
+ module Actions
3
+ class FindCommitsAction < Action
4
+ def self.run(params)
5
+ regex = Regexp.new(params[:matching])
6
+ changelog = log(from: params[:from], to: params[:to], pretty: params[:pretty])
7
+
8
+ if changelog.to_s.empty?
9
+ UI.important('No issues found.')
10
+ return []
11
+ end
12
+
13
+ tickets = tickets(log: changelog, regex: regex)
14
+ UI.important("Additional Issues: #{tickets.join("\n")}")
15
+ return tickets
16
+ end
17
+
18
+ #####################################################
19
+ # @!group Helpers
20
+ #####################################################
21
+
22
+ def self.log(from:, to:, pretty:)
23
+ if to.to_s.empty? || from.to_s.empty?
24
+ UI.important('Git Tickets: log(to:, from:) cannot be nil')
25
+ return nil
26
+ end
27
+
28
+ other_action.changelog_from_git_commits(
29
+ between: [from, to],
30
+ pretty: pretty,
31
+ merge_commit_filtering: :exclude_merges.to_s
32
+ )
33
+ end
34
+
35
+ def self.tickets(log:, regex:)
36
+ return [] if log.to_s.empty?
37
+
38
+ log.each_line
39
+ .map(&:strip)
40
+ .grep(regex)
41
+ .flatten
42
+ .reject(&:empty?)
43
+ .uniq
44
+ end
45
+
46
+ #####################################################
47
+ # @!group Documentation
48
+ #####################################################
49
+
50
+ def self.details
51
+ 'Extracts additional issues from the log'
52
+ end
53
+
54
+ def self.is_supported?(platform)
55
+ platform == :ios
56
+ end
57
+
58
+ def self.output
59
+ [String]
60
+ end
61
+
62
+ def self.available_options
63
+ [
64
+ FastlaneCore::ConfigItem.new(
65
+ key: :from,
66
+ env_name: 'FL_FIND_COMMITS_FROM',
67
+ description: 'start commit',
68
+ optional: true,
69
+ default_value: ENV['FL_FIND_TICKETS_FROM'] || 'HEAD'
70
+ ),
71
+ FastlaneCore::ConfigItem.new(
72
+ key: :to,
73
+ env_name: 'FL_FIND_COMMITS_TO',
74
+ description: 'end commit',
75
+ optional: true,
76
+ default_value: ENV['FL_FIND_TICKETS_TO'] || ENV['GIT_PREVIOUS_SUCCESSFUL_COMMIT'] || 'HEAD'
77
+ ),
78
+ FastlaneCore::ConfigItem.new(
79
+ key: :matching,
80
+ env_name: 'FL_FIND_COMMITS_MATCHING',
81
+ description: 'regex to only include to the change log',
82
+ optional: true,
83
+ default_value: ENV['FL_FIND_TICKETS_MATCHING'] || '([A-Z]+-\d+)'
84
+ ),
85
+ FastlaneCore::ConfigItem.new(
86
+ key: :pretty,
87
+ env_name: 'FL_FIND_COMMITS_PRETTY_FORMAT',
88
+ description: 'git pretty format',
89
+ optional: true,
90
+ default_value: ENV['FL_FIND_TICKETS_PRETTY_FORMAT'] || '%s'
91
+ )
92
+ ]
93
+ end
94
+
95
+ def self.author
96
+ 'Syd Srirak <sydney.srirak@outware.com.au>'
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,114 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/cerberus_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class FindTicketsAction < Action
7
+ def self.run(params)
8
+ regex = Regexp.new(params[:matching])
9
+ changelog = log(from: params[:from], to: params[:to], pretty: params[:pretty])
10
+
11
+ if changelog.to_s.empty?
12
+ UI.important('Git Tickets: No changes found.')
13
+ return []
14
+ end
15
+
16
+ tickets = tickets(log: changelog, regex: regex)
17
+ exclude_regex = Regexp.new(params[:excluding]) unless params[:excluding].to_s.empty?
18
+ tickets = filter_tickets(tickets: tickets, exclude_regex: exclude_regex) if exclude_regex
19
+ UI.important("Jira Issues: #{tickets.join(', ')}")
20
+ return tickets
21
+ end
22
+
23
+ #####################################################
24
+ # @!group Helpers
25
+ #####################################################
26
+
27
+ def self.log(from:, to:, pretty:)
28
+ if to.to_s.empty? || from.to_s.empty?
29
+ UI.important('Git Tickets: log(to:, from:) cannot be nil')
30
+ return nil
31
+ end
32
+
33
+ other_action.changelog_from_git_commits(
34
+ between: [from, to],
35
+ pretty: pretty,
36
+ merge_commit_filtering: :exclude_merges.to_s
37
+ )
38
+ end
39
+
40
+ def self.tickets(log:, regex:)
41
+ return [] if log.to_s.empty?
42
+ log.each_line
43
+ .map { |line| line.strip.scan(regex) }
44
+ .flatten
45
+ .reject(&:empty?)
46
+ .uniq
47
+ end
48
+
49
+ def self.filter_tickets(tickets:, exclude_regex:)
50
+ return [] if tickets.to_s.empty?
51
+ tickets.each.grep_v(exclude_regex)
52
+ end
53
+
54
+ #####################################################
55
+ # @!group Documentation
56
+ #####################################################
57
+
58
+ def self.details
59
+ 'Extracts the Jira issue keys between commits'
60
+ end
61
+
62
+ def self.is_supported?(platform)
63
+ platform == :ios
64
+ end
65
+
66
+ def self.output
67
+ [String]
68
+ end
69
+
70
+ def self.available_options
71
+ [
72
+ FastlaneCore::ConfigItem.new(
73
+ key: :from,
74
+ env_name: 'FL_FIND_TICKETS_FROM',
75
+ description: 'start commit',
76
+ optional: true,
77
+ default_value: 'HEAD'
78
+ ),
79
+ FastlaneCore::ConfigItem.new(
80
+ key: :to,
81
+ env_name: 'FL_FIND_TICKETS_TO',
82
+ description: 'end commit',
83
+ optional: true,
84
+ default_value: ENV['GIT_PREVIOUS_SUCCESSFUL_COMMIT'] || 'HEAD'
85
+ ),
86
+ FastlaneCore::ConfigItem.new(
87
+ key: :matching,
88
+ env_name: 'FL_FIND_TICKETS_MATCHING',
89
+ description: 'regex to extract ticket numbers',
90
+ optional: true,
91
+ default_value: '([A-Z]+-\d+)'
92
+ ),
93
+ FastlaneCore::ConfigItem.new(
94
+ key: :excluding,
95
+ env_name: 'FL_FIND_TICKETS_EXCLUDING',
96
+ description: 'regex to exclude from the change log',
97
+ optional: true
98
+ ),
99
+ FastlaneCore::ConfigItem.new(
100
+ key: :pretty,
101
+ env_name: 'FL_FIND_TICKETS_PRETTY_FORMAT',
102
+ description: 'git pretty format',
103
+ optional: true,
104
+ default_value: '* (%h) %s'
105
+ )
106
+ ]
107
+ end
108
+
109
+ def self.author
110
+ 'Harry Singh <hhs4harry@gmail.com>'
111
+ end
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,134 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/cerberus_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class JiraCommentAction < Action
7
+ def self.run(params)
8
+ issues = params[:issues]
9
+ return if issues.to_a.empty?
10
+
11
+ jira_helper = Helper::CerberusHelper.jira_helper(
12
+ host: params[:host],
13
+ username: params[:username],
14
+ password: params[:password],
15
+ context_path: params[:context_path],
16
+ disable_ssl_verification: params[:disable_ssl_verification]
17
+ )
18
+ issues = jira_helper.get(issues: issues)
19
+
20
+ comment = generate_comment(
21
+ build_number: params[:build_number],
22
+ build_url: params[:build_url],
23
+ app_version: params[:app_version],
24
+ hockey_url: params[:hockey_url]
25
+ )
26
+
27
+ jira_helper.add_comment(
28
+ comment: comment,
29
+ issues: issues
30
+ )
31
+ end
32
+
33
+ #####################################################
34
+ # @!group Helpers
35
+ #####################################################
36
+
37
+ def self.generate_comment(build_number:, build_url:, app_version:, hockey_url:)
38
+ [
39
+ "Jenkins: [Build ##{build_number}|#{build_url}]",
40
+ "HockeyApp: [Version #{app_version} (#{build_number})|#{hockey_url}]"
41
+ ].join("\n")
42
+ end
43
+
44
+ #####################################################
45
+ # @!group Documentation
46
+ #####################################################
47
+
48
+ def self.details
49
+ 'This action adds comments on Jira issues with the current build number and url of that build'
50
+ end
51
+
52
+ def self.is_supported?(platform)
53
+ platform == :ios
54
+ end
55
+
56
+ def self.available_options
57
+ [
58
+ FastlaneCore::ConfigItem.new(
59
+ key: :issues,
60
+ env_name: 'FL_JIRA_COMMENT_ISSUES',
61
+ description: 'jira issue keys',
62
+ optional: true,
63
+ default_value: [],
64
+ type: Array
65
+ ),
66
+ FastlaneCore::ConfigItem.new(
67
+ key: :build_number,
68
+ env_name: 'FL_JIRA_COMMENT_BUILD_NUMBER',
69
+ description: 'CI build number',
70
+ optional: true,
71
+ default_value: ENV['BUILD_NUMBER']
72
+ ),
73
+ FastlaneCore::ConfigItem.new(
74
+ key: :build_url,
75
+ env_name: 'FL_JIRA_COMMENT_BUILD_URL',
76
+ description: 'CI build URL',
77
+ optional: true,
78
+ default_value: ENV['BUILD_URL']
79
+ ),
80
+ FastlaneCore::ConfigItem.new(
81
+ key: :app_version,
82
+ env_name: 'FL_JIRA_COMMENT_APP_VERSION',
83
+ description: 'App version',
84
+ optional: false
85
+ ),
86
+ FastlaneCore::ConfigItem.new(
87
+ key: :hockey_url,
88
+ env_name: 'FL_JIRA_COMMENT_HOCKEY_URL',
89
+ description: 'Hockey build url',
90
+ optional: true,
91
+ default_value: Actions.lane_context[SharedValues::HOCKEY_DOWNLOAD_LINK]
92
+ ),
93
+ FastlaneCore::ConfigItem.new(
94
+ key: :username,
95
+ env_name: 'FL_JIRA_USERNAME',
96
+ description: 'Jira user',
97
+ optional: false
98
+ ),
99
+ FastlaneCore::ConfigItem.new(
100
+ key: :password,
101
+ env_name: 'FL_JIRA_PASSWORD',
102
+ description: 'Jira user',
103
+ optional: false
104
+ ),
105
+ FastlaneCore::ConfigItem.new(
106
+ key: :host,
107
+ env_name: 'FL_JIRA_HOST',
108
+ description: 'Jira location',
109
+ optional: false
110
+ ),
111
+ FastlaneCore::ConfigItem.new(
112
+ key: :context_path,
113
+ env_name: 'FL_JIRA_CONTEXT_PATH',
114
+ description: 'Jira context path',
115
+ optional: true,
116
+ default_value: ''
117
+ ),
118
+ FastlaneCore::ConfigItem.new(
119
+ key: :disable_ssl_verification,
120
+ env_name: 'FL_JIRA_DISABLE_SSL_VERIFICATION',
121
+ description: 'Jira SSL Verification mode',
122
+ optional: true,
123
+ default_value: false,
124
+ type: Boolean
125
+ )
126
+ ]
127
+ end
128
+
129
+ def self.author
130
+ 'Harry Singh <hhs4harry@gmail.com>'
131
+ end
132
+ end
133
+ end
134
+ end
@@ -0,0 +1,132 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/cerberus_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class ReleaseNotesAction < Action
7
+ def self.run(params)
8
+ @jira_helper = Helper::CerberusHelper.jira_helper(
9
+ host: params[:host],
10
+ username: params[:username],
11
+ password: params[:password],
12
+ context_path: params[:context_path],
13
+ disable_ssl_verification: params[:disable_ssl_verification]
14
+ )
15
+ issues = @jira_helper.get(issues: params[:issues])
16
+ Actions.lane_context[SharedValues::FL_CHANGELOG] = comment(issues: issues, include_commits: params[:include_commits], url: params[:build_url])
17
+ end
18
+
19
+ #####################################################
20
+ # @!group Helpers
21
+ #####################################################
22
+
23
+ def self.format(issue:)
24
+ "[#{issue.key}](#{@jira_helper.url(issue: issue)}) - #{issue.summary}"
25
+ end
26
+
27
+ def self.format_issues(issues:, include_commits:)
28
+ issues.map { |issue| format(issue: issue) }
29
+ .concat(include_commits)
30
+ .map { |change| change.prepend("- ") }
31
+ .join("\n")
32
+ end
33
+
34
+ def self.comment(issues:, include_commits:, url:)
35
+ changes = format_issues(issues: issues, include_commits: include_commits)
36
+ changes = 'No changes included.' if changes.to_s.empty?
37
+
38
+ changelog = [
39
+ '### Changelog',
40
+ '',
41
+ changes,
42
+ '',
43
+ "Built by [Jenkins](#{url})"
44
+ ].join("\n")
45
+
46
+ UI.important(changelog)
47
+ return changelog
48
+ end
49
+
50
+ #####################################################
51
+ # @!group Documentation
52
+ #####################################################
53
+
54
+ def self.details
55
+ 'Creates a markdown friendly change log from the Jira issues and the Jenkins build url'
56
+ end
57
+
58
+ def self.is_supported?(platform)
59
+ platform == :ios
60
+ end
61
+
62
+ def self.output
63
+ String
64
+ end
65
+
66
+ def self.available_options
67
+ [
68
+ FastlaneCore::ConfigItem.new(
69
+ key: :issues,
70
+ env_name: 'FL_RELEASE_NOTES_ISSUES',
71
+ description: 'Jira issues',
72
+ optional: true,
73
+ default_value: [],
74
+ type: Array
75
+ ),
76
+ FastlaneCore::ConfigItem.new(
77
+ key: :include_commits,
78
+ env_name: 'FL_HOCKEY_COMMENT_INCLUDE_COMMITS',
79
+ description: 'Additional commits',
80
+ optional: true,
81
+ default_value: [],
82
+ type: Array
83
+ ),
84
+ FastlaneCore::ConfigItem.new(
85
+ key: :build_url,
86
+ env_name: 'FL_RELEASE_NOTES_BUILD_URL',
87
+ description: 'Link to the ci build',
88
+ optional: true,
89
+ default_value: ENV['BUILD_URL']
90
+ ),
91
+ FastlaneCore::ConfigItem.new(
92
+ key: :username,
93
+ env_name: 'FL_JIRA_USERNAME',
94
+ description: 'Jira user',
95
+ optional: false
96
+ ),
97
+ FastlaneCore::ConfigItem.new(
98
+ key: :password,
99
+ env_name: 'FL_JIRA_PASSWORD',
100
+ description: 'Jira user',
101
+ optional: false
102
+ ),
103
+ FastlaneCore::ConfigItem.new(
104
+ key: :host,
105
+ env_name: 'FL_JIRA_HOST',
106
+ description: 'Jira location',
107
+ optional: false
108
+ ),
109
+ FastlaneCore::ConfigItem.new(
110
+ key: :context_path,
111
+ env_name: 'FL_JIRA_CONTEXT_PATH',
112
+ description: 'Jira context path',
113
+ optional: true,
114
+ default_value: ''
115
+ ),
116
+ FastlaneCore::ConfigItem.new(
117
+ key: :disable_ssl_verification,
118
+ env_name: 'FL_JIRA_DISABLE_SSL_VERIFICATION',
119
+ description: 'Jira SSL Verification mode',
120
+ optional: true,
121
+ default_value: false,
122
+ type: Boolean
123
+ )
124
+ ]
125
+ end
126
+
127
+ def self.author
128
+ 'Harry Singh <hhs4harry@gmail.com>'
129
+ end
130
+ end
131
+ end
132
+ end
@@ -0,0 +1,80 @@
1
+ require 'fastlane_core/ui/ui'
2
+ require 'jira-ruby'
3
+
4
+ module Fastlane
5
+ UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
6
+
7
+ module Helper
8
+ class CerberusHelper
9
+ class JiraClientHelper
10
+ def self.client(host:, username:, password:, context_path:, disable_ssl_verification:)
11
+ options = {
12
+ site: host,
13
+ context_path: context_path,
14
+ auth_type: :basic,
15
+ username: username,
16
+ password: password,
17
+ ssl_verify_mode: disable_ssl_verification ? OpenSSL::SSL::VERIFY_NONE : OpenSSL::SSL::VERIFY_PEER
18
+ }
19
+
20
+ JIRA::Client.new(options)
21
+ end
22
+ end
23
+
24
+ class JiraHelper
25
+ def initialize(host:, username:, password:, context_path:, disable_ssl_verification:, jira_client_helper: nil)
26
+ @host = host
27
+ @context_path = context_path
28
+
29
+ jira_client_helper ||= JiraClientHelper.client(
30
+ host: host,
31
+ username: username,
32
+ password: password,
33
+ context_path: context_path,
34
+ disable_ssl_verification: disable_ssl_verification
35
+ )
36
+ @client = jira_client_helper
37
+ end
38
+
39
+ def get(issues:)
40
+ return [] if issues.to_a.empty?
41
+
42
+ begin
43
+ @client.Issue.jql("KEY IN (#{issues.join(',')})", fields: [:key, :summary], validate_query: false)
44
+ rescue => e
45
+ UI.important('Jira Client: Failed to get issue.')
46
+ UI.important("Jira Client: Reason - #{e.message}")
47
+ []
48
+ end
49
+ end
50
+
51
+ def add_comment(comment:, issues:)
52
+ return if issues.to_a.empty?
53
+
54
+ issues.each do |issue|
55
+ begin
56
+ issue.comments.build.save({ 'body' => comment })
57
+ rescue => e
58
+ UI.important("Jira Client: Failed to comment on issues - #{issue.key}")
59
+ UI.important("Jira Client: Reason - #{e.message}")
60
+ end
61
+ end
62
+ end
63
+
64
+ def url(issue:)
65
+ [@host, @context_path, 'browse', issue.key].reject(&:empty?).join('/')
66
+ end
67
+ end
68
+
69
+ def self.jira_helper(host:, username:, password:, context_path:, disable_ssl_verification:)
70
+ JiraHelper.new(
71
+ host: host,
72
+ username: username,
73
+ password: password,
74
+ context_path: context_path,
75
+ disable_ssl_verification: disable_ssl_verification
76
+ )
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module Cerberus
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,193 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-cerberus
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Harry Singh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-09-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jira-ruby
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec_junit_formatter
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 0.49.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 0.49.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-require_tools
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: simplecov
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: fastlane
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: 2.99.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: 2.99.0
153
+ description:
154
+ email: hhs4harry@gmail.com
155
+ executables: []
156
+ extensions: []
157
+ extra_rdoc_files: []
158
+ files:
159
+ - LICENSE
160
+ - README.md
161
+ - lib/fastlane/plugin/cerberus.rb
162
+ - lib/fastlane/plugin/cerberus/actions/find_commits_action.rb
163
+ - lib/fastlane/plugin/cerberus/actions/find_tickets_action.rb
164
+ - lib/fastlane/plugin/cerberus/actions/jira_comment_action.rb
165
+ - lib/fastlane/plugin/cerberus/actions/release_notes_action.rb
166
+ - lib/fastlane/plugin/cerberus/helper/cerberus_helper.rb
167
+ - lib/fastlane/plugin/cerberus/version.rb
168
+ homepage: https://github.com/outware/fastlane-plugin-cerberus
169
+ licenses:
170
+ - MIT
171
+ metadata: {}
172
+ post_install_message:
173
+ rdoc_options: []
174
+ require_paths:
175
+ - lib
176
+ required_ruby_version: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ required_rubygems_version: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
186
+ requirements: []
187
+ rubyforge_project:
188
+ rubygems_version: 2.5.2
189
+ signing_key:
190
+ specification_version: 4
191
+ summary: Cerberus is a fastlane plugin for extracting Jira issues from commit messages
192
+ and sharing information on its respective Jenkins job and HockeyApp upload.
193
+ test_files: []