fastlane-plugin-jira_build_number 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 +79 -0
- data/lib/fastlane/plugin/jira_build_number.rb +16 -0
- data/lib/fastlane/plugin/jira_build_number/actions/jira_build_number_action.rb +161 -0
- data/lib/fastlane/plugin/jira_build_number/helper/jira_build_number_helper.rb +16 -0
- data/lib/fastlane/plugin/jira_build_number/version.rb +5 -0
- metadata +77 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bf54a0b5df5f6bf291c85d8c63c3bff81970efc6395fbb9514ab86704aded314
|
4
|
+
data.tar.gz: d39cc6fca41270e2b87e5ce10f6b3c74bfb238fe3d64349708010b0895fe5c71
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 49b5eb17ecf81e04cdbb537116a2018ed9b10f68da705d965222b22b9dde78dbb69b8b07ae672111a5b672feb607cc5f825a59b744d6a3162765991149b3a423
|
7
|
+
data.tar.gz: 8285cc079090b4778b340d67f54ec0a2a91847776f15a65e487e03f0b85d079840dee5e5c4ab26a6e08b185aa798c618b739c7787854cfed883a013679f704eb
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Tom Elrod <tom.elrod@goziohealth.com>
|
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,79 @@
|
|
1
|
+
# jira\_build\_number plugin
|
2
|
+
|
3
|
+
[](https://rubygems.org/gems/fastlane-plugin-jira_build_number)
|
4
|
+
|
5
|
+
## Getting Started
|
6
|
+
|
7
|
+
This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-jira_build_number`, add it to your project by running:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
fastlane add_plugin jira_build_number
|
11
|
+
```
|
12
|
+
|
13
|
+
## About jira\_build\_number
|
14
|
+
|
15
|
+
Insert build number into related jira issues based on commit message or branch containing a jira issue id. This plugin is intended to be triggered by CI service such as CircleCI or bitrise upon pushing code to a repository.
|
16
|
+
|
17
|
+
This plugin requires the following parameters be set or generated and passed to the plugin:
|
18
|
+
* commit_message - the last commit message
|
19
|
+
* commit_branch - the branch on which the commit occurred
|
20
|
+
* version_code - the build number for the code being compiled (e.g. 238)
|
21
|
+
* version_name - the version number for the code being compiled (e.g. 1.0.1)
|
22
|
+
* jira_hostname - the URL of the jira instance you are using
|
23
|
+
* jira_username - the jira username to use to access jira
|
24
|
+
* jira_password - the jira password to use to access jira
|
25
|
+
|
26
|
+
If the plugin can find a jira issue id in either the commit message or the branch name, it will insert a comment into the jira issue with the provided build number.
|
27
|
+
|
28
|
+
## Example
|
29
|
+
|
30
|
+
The following is an example of a lane within Fastline file.
|
31
|
+
|
32
|
+
```
|
33
|
+
desc "Execute jira build number plugin"
|
34
|
+
lane :jira_build_number do
|
35
|
+
commit = last_git_commit
|
36
|
+
commit_message = commit[:message]
|
37
|
+
commit_branch = git_branch
|
38
|
+
version_code = %x(git rev-list --count HEAD)
|
39
|
+
version_name = get_version_name(
|
40
|
+
gradle_file_path:"app/build.gradle"
|
41
|
+
)
|
42
|
+
puts "Build number: " + version_code
|
43
|
+
puts "Version name: " + version_name
|
44
|
+
jira_hostname = ENV["JIRA_HOSTNAME"]
|
45
|
+
jira_username = ENV["JIRA_USERNAME"]
|
46
|
+
jira_password = ENV["JIRA_PASSWORD"]
|
47
|
+
jira_build_number(commit_message: commit_message, commit_branch: commit_branch, build_number: version_code, version_name: version_name, jira_hostname: jira_hostname, jira_username: jira_username, jira_password: jira_password)
|
48
|
+
end
|
49
|
+
|
50
|
+
```
|
51
|
+
|
52
|
+
## Run tests for this plugin
|
53
|
+
|
54
|
+
To run both the tests, and code style validation, run
|
55
|
+
|
56
|
+
```
|
57
|
+
rake
|
58
|
+
```
|
59
|
+
|
60
|
+
To automatically fix many of the styling issues, use
|
61
|
+
```
|
62
|
+
rubocop -a
|
63
|
+
```
|
64
|
+
|
65
|
+
## Issues and Feedback
|
66
|
+
|
67
|
+
For any other issues and feedback about this plugin, please submit it to this repository.
|
68
|
+
|
69
|
+
## Troubleshooting
|
70
|
+
|
71
|
+
If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
|
72
|
+
|
73
|
+
## Using _fastlane_ Plugins
|
74
|
+
|
75
|
+
For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
|
76
|
+
|
77
|
+
## About _fastlane_
|
78
|
+
|
79
|
+
_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/jira_build_number/version'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
module JiraBuildNumber
|
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::JiraBuildNumber.all_classes.each do |current|
|
15
|
+
require current
|
16
|
+
end
|
@@ -0,0 +1,161 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/jira_build_number_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
module SharedValues
|
7
|
+
JIRA_ISSUE_ID_VALUE = :JIRA_ISSUE_ID_VALUE
|
8
|
+
end
|
9
|
+
|
10
|
+
class JiraBuildNumberAction < Action
|
11
|
+
def self.run(params)
|
12
|
+
UI.message("Running jira build number action...")
|
13
|
+
|
14
|
+
UI.message "Commit message: #{params[:commit_message]}"
|
15
|
+
UI.message "Commit branch: #{params[:commit_branch]}"
|
16
|
+
|
17
|
+
commitMessage = params[:commit_message]
|
18
|
+
commitBranch = params[:commit_branch]
|
19
|
+
|
20
|
+
# jiraTicketId = commitMessage.match((?<!([A-Za-z]{1,10})-?)[A-Z]+-\d+))
|
21
|
+
jiraTicketId = searchForJiraTicketId(commitMessage)
|
22
|
+
|
23
|
+
#UI.message "Jira ticket id: #{jiraTicketId}"
|
24
|
+
|
25
|
+
if(jiraTicketId.nil?)
|
26
|
+
jiraTicketId = searchForJiraTicketId(commitBranch)
|
27
|
+
end
|
28
|
+
|
29
|
+
UI.message "Jira ticket id: #{jiraTicketId}"
|
30
|
+
|
31
|
+
buildNumber = params[:build_number]
|
32
|
+
buildVersion = params[:version_name]
|
33
|
+
|
34
|
+
UI.message "Build version: #{buildVersion}"
|
35
|
+
UI.message "Build number: #{buildNumber}"
|
36
|
+
|
37
|
+
jiraHostname = params[:jira_hostname]
|
38
|
+
#jiraBasicToken = params[:jira_token]
|
39
|
+
jiraUsername = params[:jira_username]
|
40
|
+
jiraPassword = params[:jira_password]
|
41
|
+
|
42
|
+
jiraBasicToken = Base64.encode64("#{jiraUsername}:#{jiraPassword}")
|
43
|
+
|
44
|
+
if(!jiraTicketId.nil?)
|
45
|
+
response = RestClient.post "https://#{jiraHostname}/rest/api/2/issue/#{jiraTicketId}/comment",
|
46
|
+
"{\"body\": \"Build: #{buildVersion}.#{buildNumber}\"}",
|
47
|
+
{content_type: "application/json", Authorization: "Basic #{jiraBasicToken}"}
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
#UI.message "Jira post response: #{response}"
|
52
|
+
|
53
|
+
# sh "shellcommand ./path"
|
54
|
+
|
55
|
+
# Actions.lane_context[SharedValues::JIRA_BUILD_NUMBER_CUSTOM_VALUE] = "my_val"
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.searchForJiraTicketId(str)
|
59
|
+
/[A-Z]+[-](\d+)/.match(str)
|
60
|
+
end
|
61
|
+
|
62
|
+
#####################################################
|
63
|
+
# @!group Documentation
|
64
|
+
#####################################################
|
65
|
+
|
66
|
+
def self.description
|
67
|
+
"Adds build number from CI as comment to associated jira issue."
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.details
|
71
|
+
# Optional:
|
72
|
+
# this is your chance to provide a more detailed description of this action
|
73
|
+
"Looks for the jira issue id in the branch or commit message and will insert the build number as a comment into that jira issue if found."
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.available_options
|
77
|
+
# Define all options your action supports.
|
78
|
+
|
79
|
+
# Below a few examples
|
80
|
+
[
|
81
|
+
FastlaneCore::ConfigItem.new(key: :jira_username,
|
82
|
+
env_name: "FL_JIRA_BUILD_NUMBER_JIRA_USERNAME", # The name of the environment variable
|
83
|
+
description: "Jira username for JiraBuildNumberAction", # a short description of this parameter
|
84
|
+
verify_block: proc do |value|
|
85
|
+
UI.user_error!("No jira username for JiraBuildNumberAction given, pass using `build_number: 'build'`") unless (value and not value.empty?)
|
86
|
+
# UI.user_error!("Couldn't find file at path '#{value}'") unless File.exist?(value)
|
87
|
+
end),
|
88
|
+
FastlaneCore::ConfigItem.new(key: :jira_password,
|
89
|
+
env_name: "FL_JIRA_BUILD_NUMBER_JIRA_PASSWORD", # The name of the environment variable
|
90
|
+
description: "Jira password for JiraBuildNumberAction", # a short description of this parameter
|
91
|
+
verify_block: proc do |value|
|
92
|
+
UI.user_error!("No jira password for JiraBuildNumberAction given, pass using `build_number: 'build'`") unless (value and not value.empty?)
|
93
|
+
# UI.user_error!("Couldn't find file at path '#{value}'") unless File.exist?(value)
|
94
|
+
end),
|
95
|
+
FastlaneCore::ConfigItem.new(key: :jira_hostname,
|
96
|
+
env_name: "FL_JIRA_BUILD_NUMBER_JIRA_HOSTNAME", # The name of the environment variable
|
97
|
+
description: "Jira hostname for JiraBuildNumberAction", # a short description of this parameter
|
98
|
+
verify_block: proc do |value|
|
99
|
+
UI.user_error!("No jira hostname for JiraBuildNumberAction given, pass using `build_number: 'build'`") unless (value and not value.empty?)
|
100
|
+
# UI.user_error!("Couldn't find file at path '#{value}'") unless File.exist?(value)
|
101
|
+
end),
|
102
|
+
FastlaneCore::ConfigItem.new(key: :jira_token,
|
103
|
+
env_name: "FL_JIRA_BUILD_NUMBER_JIRA_TOKEN", # The name of the environment variable
|
104
|
+
description: "Jira token for JiraBuildNumberAction", # a short description of this parameter
|
105
|
+
verify_block: proc do |value|
|
106
|
+
UI.user_error!("No jira basic token for JiraBuildNumberAction given, pass using `build_number: 'build'`") unless (value and not value.empty?)
|
107
|
+
# UI.user_error!("Couldn't find file at path '#{value}'") unless File.exist?(value)
|
108
|
+
end),
|
109
|
+
FastlaneCore::ConfigItem.new(key: :build_number,
|
110
|
+
env_name: "FL_JIRA_BUILD_NUMBER_BUILD_NUMBER", # The name of the environment variable
|
111
|
+
description: "Build number for JiraBuildNumberAction", # a short description of this parameter
|
112
|
+
verify_block: proc do |value|
|
113
|
+
UI.user_error!("No build number for JiraBuildNumberAction given, pass using `build_number: 'build'`") unless (value and not value.empty?)
|
114
|
+
# UI.user_error!("Couldn't find file at path '#{value}'") unless File.exist?(value)
|
115
|
+
end),
|
116
|
+
FastlaneCore::ConfigItem.new(key: :version_name,
|
117
|
+
env_name: "FL_JIRA_BUILD_NUMBER_VERSION_NAME", # The name of the environment variable
|
118
|
+
description: "Build version for JiraBuildNumberAction", # a short description of this parameter
|
119
|
+
verify_block: proc do |value|
|
120
|
+
UI.user_error!("No build version for JiraBuildNumberAction given, pass using `version_name: 'version'`") unless (value and not value.empty?)
|
121
|
+
# UI.user_error!("Couldn't find file at path '#{value}'") unless File.exist?(value)
|
122
|
+
end),
|
123
|
+
FastlaneCore::ConfigItem.new(key: :commit_branch,
|
124
|
+
env_name: "FL_JIRA_BUILD_NUMBER_COMMIT_BRANCH", # The name of the environment variable
|
125
|
+
description: "Commit branch for JiraBuildNumberAction", # a short description of this parameter
|
126
|
+
verify_block: proc do |value|
|
127
|
+
UI.user_error!("No commit branch for JiraBuildNumberAction given, pass using `commit_branch: 'branch'`") unless (value and not value.empty?)
|
128
|
+
# UI.user_error!("Couldn't find file at path '#{value}'") unless File.exist?(value)
|
129
|
+
end),
|
130
|
+
FastlaneCore::ConfigItem.new(key: :commit_message,
|
131
|
+
env_name: "FL_JIRA_BUILD_NUMBER_COMMIT_MESSAGE", # The name of the environment variable
|
132
|
+
description: "Commit message for JiraBuildNumberAction", # a short description of this parameter
|
133
|
+
verify_block: proc do |value|
|
134
|
+
UI.user_error!("No commit message for JiraBuildNumberAction given, pass using `commit_message: 'message'`") unless (value and not value.empty?)
|
135
|
+
# UI.user_error!("Couldn't find file at path '#{value}'") unless File.exist?(value)
|
136
|
+
end)
|
137
|
+
]
|
138
|
+
end
|
139
|
+
|
140
|
+
def self.output
|
141
|
+
[
|
142
|
+
['JIRA_ISSUE_ID_VALUE', 'The jira issue id if found within comment or branch name']
|
143
|
+
]
|
144
|
+
end
|
145
|
+
|
146
|
+
def self.return_value
|
147
|
+
"Returns jira issue id if found within comment or branch"
|
148
|
+
end
|
149
|
+
|
150
|
+
def self.authors
|
151
|
+
["https://github.com/telrod"]
|
152
|
+
end
|
153
|
+
|
154
|
+
def self.is_supported?(platform)
|
155
|
+
# true
|
156
|
+
[:ios, :android].include?(platform)
|
157
|
+
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
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 JiraBuildNumberHelper
|
8
|
+
# class methods that you define here become available in your action
|
9
|
+
# as `Helper::JiraBuildNumberHelper.your_method`
|
10
|
+
#
|
11
|
+
def self.show_message
|
12
|
+
UI.message("Hello from the jira_build_number plugin helper!")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fastlane-plugin-jira_build_number
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tom Elrod
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-10-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fastlane
|
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
|
+
description:
|
42
|
+
email: tom.elrod@gmail.com
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- LICENSE
|
48
|
+
- README.md
|
49
|
+
- lib/fastlane/plugin/jira_build_number.rb
|
50
|
+
- lib/fastlane/plugin/jira_build_number/actions/jira_build_number_action.rb
|
51
|
+
- lib/fastlane/plugin/jira_build_number/helper/jira_build_number_helper.rb
|
52
|
+
- lib/fastlane/plugin/jira_build_number/version.rb
|
53
|
+
homepage: https://github.com/telrod/fastlane-plugin-jira_build_number
|
54
|
+
licenses:
|
55
|
+
- MIT
|
56
|
+
metadata: {}
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
requirements: []
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 2.7.7
|
74
|
+
signing_key:
|
75
|
+
specification_version: 4
|
76
|
+
summary: Insert build number into related jira issues
|
77
|
+
test_files: []
|