fastlane-plugin-jira_util 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +54 -0
- data/lib/fastlane/plugin/jira_util.rb +16 -0
- data/lib/fastlane/plugin/jira_util/actions/create_jira_issue.rb +169 -0
- data/lib/fastlane/plugin/jira_util/actions/create_jira_version.rb +173 -0
- data/lib/fastlane/plugin/jira_util/actions/release_jira_version.rb +166 -0
- data/lib/fastlane/plugin/jira_util/helper/jira_util_helper.rb +16 -0
- data/lib/fastlane/plugin/jira_util/version.rb +5 -0
- metadata +191 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: eddfa8f7e45fb3d44fe869efd394238fe0eb6779
|
4
|
+
data.tar.gz: 928b353c89e661a5c1e7da5ef3ff21af2d6f878f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e7c18af578751f15de805e0d6a08f64066f0e65bc2a5d304a615ac131113c21164fa994ebcce843d63e816202053462d0a4ed3c04903764c23f6939ac0306525
|
7
|
+
data.tar.gz: 6c24c22a2e5d4e7a29650c399073bd8838439d3aabcd4e1b0480f3561c0a0e04b7daa3d2173436cef7b5c8e8981c57c1bf45b4eb010e2b87cf9fa14aa1378c5d
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Sandy Chapman <sandychapman@gmail.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,54 @@
|
|
1
|
+
# jira_util fastlane plugin
|
2
|
+
|
3
|
+
[![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-jira_util)
|
4
|
+
|
5
|
+
## Getting Started
|
6
|
+
|
7
|
+
This project is a [fastlane](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-jira_util`, add it to your project by running:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
fastlane add_plugin jira_util
|
11
|
+
```
|
12
|
+
|
13
|
+
## About jira_util
|
14
|
+
|
15
|
+
Manage your JIRA project's releases/versions with this plugin.
|
16
|
+
|
17
|
+
Currently, jira_util comes with three actions, `create_jira_issue`, `create_jira_version` and `release_jira_version`. The first will create a new issue in your JIRA project, second will create a new version and the third will release a version.
|
18
|
+
|
19
|
+
## Create Version Example
|
20
|
+
|
21
|
+
Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins`, modifying the placeholder variables in the Fastfile lane and running `bundle exec fastlane create_version`.
|
22
|
+
|
23
|
+
## Release Version Example
|
24
|
+
|
25
|
+
Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins`, modifying the placeholder variables in the Fastfile lane and running `bundle exec fastlane release_version`.
|
26
|
+
|
27
|
+
## Run tests for this plugin
|
28
|
+
|
29
|
+
To run both the tests, and code style validation, run
|
30
|
+
|
31
|
+
```
|
32
|
+
rake
|
33
|
+
```
|
34
|
+
|
35
|
+
To automatically fix many of the styling issues, use
|
36
|
+
```
|
37
|
+
rubocop -a
|
38
|
+
```
|
39
|
+
|
40
|
+
## Issues and Feedback
|
41
|
+
|
42
|
+
For any other issues and feedback about this plugin, please submit it to this repository.
|
43
|
+
|
44
|
+
## Troubleshooting
|
45
|
+
|
46
|
+
If you have trouble using plugins, check out the [Plugins Troubleshooting](https://github.com/fastlane/fastlane/blob/master/fastlane/docs/PluginsTroubleshooting.md) doc in the main `fastlane` repo.
|
47
|
+
|
48
|
+
## Using `fastlane` Plugins
|
49
|
+
|
50
|
+
For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Plugins.md).
|
51
|
+
|
52
|
+
## About `fastlane`
|
53
|
+
|
54
|
+
`fastlane` is the easiest way to automate building and releasing your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'fastlane/plugin/jira_util/version'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
module JiraUtil
|
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::JiraUtil.all_classes.each do |current|
|
15
|
+
require current
|
16
|
+
end
|
@@ -0,0 +1,169 @@
|
|
1
|
+
module Fastlane
|
2
|
+
module Actions
|
3
|
+
module SharedValues
|
4
|
+
CREATE_JIRA_ISSUE_ISSUE_ID = :CREATE_JIRA_ISSUE_ISSUE_ID
|
5
|
+
CREATE_JIRA_ISSUE_ISSUE_KEY = :CREATE_JIRA_ISSUE_ISSUE_KEY
|
6
|
+
end
|
7
|
+
|
8
|
+
class CreateJiraIssueAction < Action
|
9
|
+
def self.run(params)
|
10
|
+
Actions.verify_gem!('jira-ruby')
|
11
|
+
require 'jira-ruby'
|
12
|
+
|
13
|
+
site = params[:url]
|
14
|
+
context_path = ""
|
15
|
+
auth_type = :basic
|
16
|
+
username = params[:username]
|
17
|
+
password = params[:password]
|
18
|
+
project_name = params[:project_name]
|
19
|
+
issue_type_name = params[:issue_type_name]
|
20
|
+
summary = params[:summary]
|
21
|
+
version_name = params[:version_name]
|
22
|
+
description = params[:description]
|
23
|
+
|
24
|
+
options = {
|
25
|
+
username: username,
|
26
|
+
password: password,
|
27
|
+
site: site,
|
28
|
+
context_path: context_path,
|
29
|
+
auth_type: auth_type,
|
30
|
+
read_timeout: 120
|
31
|
+
}
|
32
|
+
|
33
|
+
client = JIRA::Client.new(options)
|
34
|
+
|
35
|
+
project = client.Project.find(project_name)
|
36
|
+
|
37
|
+
project_id = project.id
|
38
|
+
if project_id.nil?
|
39
|
+
raise "Project '#{project_name}' not found."
|
40
|
+
return false
|
41
|
+
end
|
42
|
+
|
43
|
+
issue_type = project.issueTypes.find { |type| type['name'] == issue_type_name }
|
44
|
+
if issue_type.nil?
|
45
|
+
raise "Issue type '#{issue_type_name}' not found."
|
46
|
+
return false
|
47
|
+
end
|
48
|
+
|
49
|
+
version = project.versions.find { |version| version.name == version_name }
|
50
|
+
if version.nil?
|
51
|
+
raise "Version '#{version_name}' not found."
|
52
|
+
return false
|
53
|
+
end
|
54
|
+
|
55
|
+
issue = client.Issue.build
|
56
|
+
issue.save!({
|
57
|
+
"fields" => {
|
58
|
+
"issuetype" => {"id" => issue_type['id']},
|
59
|
+
"project" => { "id" => project_id },
|
60
|
+
"versions" => [{"id" => version.id }],
|
61
|
+
"summary" => summary,
|
62
|
+
"description" => description
|
63
|
+
}
|
64
|
+
})
|
65
|
+
|
66
|
+
issue.fetch
|
67
|
+
Actions.lane_context[SharedValues::CREATE_JIRA_ISSUE_ISSUE_ID] = issue.id
|
68
|
+
Actions.lane_context[SharedValues::CREATE_JIRA_ISSUE_ISSUE_KEY] = issue.key
|
69
|
+
issue.id
|
70
|
+
rescue JIRA::HTTPError
|
71
|
+
UI.user_error!("Failed to create new JIRA issue: #{$!.response.body}")
|
72
|
+
false
|
73
|
+
rescue
|
74
|
+
UI.user_error!("Failed to create new JIRA issue: #{$!}")
|
75
|
+
false
|
76
|
+
end
|
77
|
+
|
78
|
+
#####################################################
|
79
|
+
# @!group Documentation
|
80
|
+
#####################################################
|
81
|
+
|
82
|
+
def self.description
|
83
|
+
"Creates a new issue in your JIRA project"
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.details
|
87
|
+
"Use this action to create a new issue in JIRA"
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.available_options
|
91
|
+
[
|
92
|
+
FastlaneCore::ConfigItem.new(key: :url,
|
93
|
+
env_name: "FL_JIRA_UTIL_SITE",
|
94
|
+
description: "URL for Jira instance",
|
95
|
+
type: String,
|
96
|
+
verify_block: proc do |value|
|
97
|
+
UI.user_error!("No url for Jira given, pass using `url: 'url'`") unless value and !value.empty?
|
98
|
+
end),
|
99
|
+
FastlaneCore::ConfigItem.new(key: :username,
|
100
|
+
env_name: "FL_JIRA_UTIL_USERNAME",
|
101
|
+
description: "Username for JIRA instance",
|
102
|
+
type: String,
|
103
|
+
verify_block: proc do |value|
|
104
|
+
UI.user_error!("No username given, pass using `username: 'jira_user'`") unless value and !value.empty?
|
105
|
+
end),
|
106
|
+
FastlaneCore::ConfigItem.new(key: :password,
|
107
|
+
env_name: "FL_JIRA_UTIL_PASSWORD",
|
108
|
+
description: "Password for Jira",
|
109
|
+
type: String,
|
110
|
+
verify_block: proc do |value|
|
111
|
+
UI.user_error!("No password given, pass using `password: 'T0PS3CR3T'`") unless value and !value.empty?
|
112
|
+
end),
|
113
|
+
FastlaneCore::ConfigItem.new(key: :project_name,
|
114
|
+
env_name: "FL_CREATE_JIRA_ISSUE_PROJECT_NAME",
|
115
|
+
description: "Project ID for the JIRA project. E.g. the short abbreviation in the JIRA ticket tags",
|
116
|
+
type: String,
|
117
|
+
verify_block: proc do |value|
|
118
|
+
UI.user_error!("No Project ID given, pass using `project_id: 'PROJID'`") unless value and !value.empty?
|
119
|
+
end),
|
120
|
+
FastlaneCore::ConfigItem.new(key: :issue_type_name,
|
121
|
+
env_name: "FL_CREATE_JIRA_ISSUE_ISSUE_TYPE_NAME",
|
122
|
+
description: "Issue type for the JIRA issue. E.g. Build, Bug, etc",
|
123
|
+
type: String,
|
124
|
+
verify_block: proc do |value|
|
125
|
+
UI.user_error!("No Issue type name given, pass using `issue_type_name: 'Bug'`") unless value and !value.empty?
|
126
|
+
end),
|
127
|
+
FastlaneCore::ConfigItem.new(key: :summary,
|
128
|
+
env_name: "FL_CREATE_JIRA_ISSUE_SUMMARY",
|
129
|
+
description: "The summary of the issue. E.g. New Issue",
|
130
|
+
type: String,
|
131
|
+
verify_block: proc do |value|
|
132
|
+
UI.user_error!("No summary given, pass using `summary: 'New Issue'`") unless value and !value.empty?
|
133
|
+
end),
|
134
|
+
FastlaneCore::ConfigItem.new(key: :version_name,
|
135
|
+
env_name: "FL_CREATE_JIRA_ISSUE_VERSION_NAME",
|
136
|
+
description: "The version name of the issue. E.g. Next_Release",
|
137
|
+
type: String,
|
138
|
+
verify_block: proc do |value|
|
139
|
+
UI.user_error!("No version_name given, pass using `version_name: 'Next_Release'`") unless value and !value.empty?
|
140
|
+
end),
|
141
|
+
FastlaneCore::ConfigItem.new(key: :description,
|
142
|
+
env_name: "FL_CREATE_JIRA_ISSUE_DESCRIPTION",
|
143
|
+
description: "The description text of the issue. E.g. This is important issue",
|
144
|
+
type: String,
|
145
|
+
optional: true)
|
146
|
+
]
|
147
|
+
end
|
148
|
+
|
149
|
+
def self.output
|
150
|
+
[
|
151
|
+
['CREATE_JIRA_ISSUE_ISSUE_ID', 'The id for the newly created JIRA issue'],
|
152
|
+
['CREATE_JIRA_ISSUE_ISSUE_KEY', 'The key (e.g. MYPOJ-123) for the newly created JIRA issue']
|
153
|
+
]
|
154
|
+
end
|
155
|
+
|
156
|
+
def self.return_value
|
157
|
+
'The id for the newly create JIRA issue'
|
158
|
+
end
|
159
|
+
|
160
|
+
def self.authors
|
161
|
+
["https://github.com/SandyChapman", "https://github.com/alexeyn-martynov"]
|
162
|
+
end
|
163
|
+
|
164
|
+
def self.is_supported?(platform)
|
165
|
+
true
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
@@ -0,0 +1,173 @@
|
|
1
|
+
module Fastlane
|
2
|
+
module Actions
|
3
|
+
module SharedValues
|
4
|
+
CREATE_JIRA_VERSION_VERSION_ID = :CREATE_JIRA_VERSION_VERSION_ID
|
5
|
+
end
|
6
|
+
|
7
|
+
class CreateJiraVersionAction < Action
|
8
|
+
def self.run(params)
|
9
|
+
Actions.verify_gem!('jira-ruby')
|
10
|
+
require 'jira-ruby'
|
11
|
+
|
12
|
+
site = params[:url]
|
13
|
+
context_path = ""
|
14
|
+
auth_type = :basic
|
15
|
+
username = params[:username]
|
16
|
+
password = params[:password]
|
17
|
+
project_name = params[:project_name]
|
18
|
+
project_id = params[:project_id]
|
19
|
+
name = params[:name]
|
20
|
+
description = params[:description]
|
21
|
+
archived = params[:archived]
|
22
|
+
released = params[:released]
|
23
|
+
start_date = params[:start_date]
|
24
|
+
|
25
|
+
options = {
|
26
|
+
username: username,
|
27
|
+
password: password,
|
28
|
+
site: site,
|
29
|
+
context_path: context_path,
|
30
|
+
auth_type: auth_type,
|
31
|
+
read_timeout: 120
|
32
|
+
}
|
33
|
+
|
34
|
+
client = JIRA::Client.new(options)
|
35
|
+
|
36
|
+
unless project_name.nil?
|
37
|
+
project = client.Project.find(project_name)
|
38
|
+
project_id = project.id
|
39
|
+
end
|
40
|
+
|
41
|
+
if start_date.nil?
|
42
|
+
start_date = Date.today.to_s
|
43
|
+
end
|
44
|
+
|
45
|
+
version = client.Version.build
|
46
|
+
version.save!({
|
47
|
+
"description" => description,
|
48
|
+
"name" => name,
|
49
|
+
"archived" => archived,
|
50
|
+
"released" => released,
|
51
|
+
"startDate" => start_date,
|
52
|
+
"projectId" => project_id
|
53
|
+
})
|
54
|
+
version.fetch
|
55
|
+
Actions.lane_context[SharedValues::CREATE_JIRA_VERSION_VERSION_ID] = version.id
|
56
|
+
version.id
|
57
|
+
rescue
|
58
|
+
UI.user_error!("Failed to create new JIRA version: #{$!.response.body}")
|
59
|
+
false
|
60
|
+
end
|
61
|
+
|
62
|
+
#####################################################
|
63
|
+
# @!group Documentation
|
64
|
+
#####################################################
|
65
|
+
|
66
|
+
def self.description
|
67
|
+
"Creates a new version in your JIRA project"
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.details
|
71
|
+
"Use this action to create a new version in JIRA"
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.available_options
|
75
|
+
[
|
76
|
+
FastlaneCore::ConfigItem.new(key: :url,
|
77
|
+
env_name: "FL_CREATE_JIRA_VERSION_SITE",
|
78
|
+
description: "URL for Jira instance",
|
79
|
+
type: String,
|
80
|
+
verify_block: proc do |value|
|
81
|
+
UI.user_error!("No url for Jira given, pass using `url: 'url'`") unless value and !value.empty?
|
82
|
+
end),
|
83
|
+
FastlaneCore::ConfigItem.new(key: :username,
|
84
|
+
env_name: "FL_CREATE_JIRA_VERSION_USERNAME",
|
85
|
+
description: "Username for JIRA instance",
|
86
|
+
type: String,
|
87
|
+
verify_block: proc do |value|
|
88
|
+
UI.user_error!("No username given, pass using `username: 'jira_user'`") unless value and !value.empty?
|
89
|
+
end),
|
90
|
+
FastlaneCore::ConfigItem.new(key: :password,
|
91
|
+
env_name: "FL_CREATE_JIRA_VERSION_PASSWORD",
|
92
|
+
description: "Password for Jira",
|
93
|
+
type: String,
|
94
|
+
verify_block: proc do |value|
|
95
|
+
UI.user_error!("No password given, pass using `password: 'T0PS3CR3T'`") unless value and !value.empty?
|
96
|
+
end),
|
97
|
+
FastlaneCore::ConfigItem.new(key: :project_name,
|
98
|
+
env_name: "FL_CREATE_JIRA_VERSION_PROJECT_NAME",
|
99
|
+
description: "Project ID for the JIRA project. E.g. the short abbreviation in the JIRA ticket tags",
|
100
|
+
type: String,
|
101
|
+
optional: true,
|
102
|
+
conflicting_options: [:project_id],
|
103
|
+
conflict_block: proc do |value|
|
104
|
+
UI.user_error!("You can't use 'project_name' and '#{project_id}' options in one run")
|
105
|
+
end,
|
106
|
+
verify_block: proc do |value|
|
107
|
+
UI.user_error!("No Project ID given, pass using `project_id: 'PROJID'`") unless value and !value.empty?
|
108
|
+
end),
|
109
|
+
FastlaneCore::ConfigItem.new(key: :project_id,
|
110
|
+
env_name: "FL_CREATE_JIRA_VERSION_PROJECT_ID",
|
111
|
+
description: "Project ID for the JIRA project. E.g. the short abbreviation in the JIRA ticket tags",
|
112
|
+
type: String,
|
113
|
+
optional: true,
|
114
|
+
conflicting_options: [:project_name],
|
115
|
+
conflict_block: proc do |value|
|
116
|
+
UI.user_error!("You can't use 'project_id' and '#{project_name}' options in one run")
|
117
|
+
end,
|
118
|
+
verify_block: proc do |value|
|
119
|
+
UI.user_error!("No Project ID given, pass using `project_id: 'PROJID'`") unless value and !value.empty?
|
120
|
+
end),
|
121
|
+
FastlaneCore::ConfigItem.new(key: :name,
|
122
|
+
env_name: "FL_CREATE_JIRA_VERSION_NAME",
|
123
|
+
description: "The name of the version. E.g. 1.0.0",
|
124
|
+
type: String,
|
125
|
+
verify_block: proc do |value|
|
126
|
+
UI.user_error!("No version name given, pass using `name: '1.0.0'`") unless value and !value.empty?
|
127
|
+
end),
|
128
|
+
FastlaneCore::ConfigItem.new(key: :description,
|
129
|
+
env_name: "FL_CREATE_JIRA_VERSION_DESCRIPTION",
|
130
|
+
description: "The description of the JIRA project version",
|
131
|
+
type: String,
|
132
|
+
optional: true,
|
133
|
+
default_value: ''),
|
134
|
+
FastlaneCore::ConfigItem.new(key: :archived,
|
135
|
+
env_name: "FL_CREATE_JIRA_VERSION_ARCHIVED",
|
136
|
+
description: "Whether the version should be archived",
|
137
|
+
optional: true,
|
138
|
+
default_value: false),
|
139
|
+
FastlaneCore::ConfigItem.new(key: :released,
|
140
|
+
env_name: "FL_CREATE_JIRA_VERSION_CREATED",
|
141
|
+
description: "Whether the version should be released",
|
142
|
+
optional: true,
|
143
|
+
default_value: false),
|
144
|
+
FastlaneCore::ConfigItem.new(key: :start_date,
|
145
|
+
env_name: "FL_CREATE_JIRA_VERSION_START_DATE",
|
146
|
+
description: "The date this version will start on",
|
147
|
+
type: String,
|
148
|
+
is_string: true,
|
149
|
+
optional: true,
|
150
|
+
default_value: Date.today.to_s)
|
151
|
+
]
|
152
|
+
end
|
153
|
+
|
154
|
+
def self.output
|
155
|
+
[
|
156
|
+
['CREATE_JIRA_VERSION_VERSION_ID', 'The versionId for the newly created JIRA project version']
|
157
|
+
]
|
158
|
+
end
|
159
|
+
|
160
|
+
def self.return_value
|
161
|
+
'The versionId for the newly create JIRA project version'
|
162
|
+
end
|
163
|
+
|
164
|
+
def self.authors
|
165
|
+
["https://github.com/SandyChapman"]
|
166
|
+
end
|
167
|
+
|
168
|
+
def self.is_supported?(platform)
|
169
|
+
true
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
module Fastlane
|
2
|
+
module Actions
|
3
|
+
module SharedValues
|
4
|
+
RELEASE_JIRA_VERSION_VERSION_ID = :RELEASE_JIRA_VERSION_VERSION_ID
|
5
|
+
end
|
6
|
+
|
7
|
+
class ReleaseJiraVersionAction < Action
|
8
|
+
def self.run(params)
|
9
|
+
Actions.verify_gem!('jira-ruby')
|
10
|
+
require 'jira-ruby'
|
11
|
+
|
12
|
+
site = params[:url]
|
13
|
+
context_path = ""
|
14
|
+
auth_type = :basic
|
15
|
+
username = params[:username]
|
16
|
+
password = params[:password]
|
17
|
+
project_name = params[:project_name]
|
18
|
+
project_id = params[:project_id]
|
19
|
+
name = params[:name]
|
20
|
+
new_name = params[:new_name]
|
21
|
+
release_date = params[:release_date]
|
22
|
+
released = true
|
23
|
+
|
24
|
+
options = {
|
25
|
+
username: username,
|
26
|
+
password: password,
|
27
|
+
site: site,
|
28
|
+
context_path: context_path,
|
29
|
+
auth_type: auth_type,
|
30
|
+
read_timeout: 120
|
31
|
+
}
|
32
|
+
|
33
|
+
client = JIRA::Client.new(options)
|
34
|
+
|
35
|
+
unless project_name.nil?
|
36
|
+
project = client.Project.find(project_name)
|
37
|
+
project_id = project.id
|
38
|
+
end
|
39
|
+
|
40
|
+
version = project.versions.find { |version| version.name == name }
|
41
|
+
if version.nil?
|
42
|
+
raise "Version '#{name}' not found."
|
43
|
+
return false
|
44
|
+
end
|
45
|
+
|
46
|
+
if new_name.nil?
|
47
|
+
new_name = name
|
48
|
+
end
|
49
|
+
version.save!({
|
50
|
+
"released" => released,
|
51
|
+
"releaseDate" => release_date,
|
52
|
+
"projectId" => project_id,
|
53
|
+
"name" => new_name
|
54
|
+
})
|
55
|
+
version.fetch
|
56
|
+
Actions.lane_context[SharedValues::RELEASE_JIRA_VERSION_VERSION_ID] = version.id
|
57
|
+
version.id
|
58
|
+
rescue RuntimeError
|
59
|
+
UI.user_error!("#{$!}")
|
60
|
+
false
|
61
|
+
rescue JIRA::HTTPError
|
62
|
+
UI.user_error!("Failed to release new JIRA version: #{$!.response.body}")
|
63
|
+
false
|
64
|
+
end
|
65
|
+
|
66
|
+
#####################################################
|
67
|
+
# @!group Documentation
|
68
|
+
#####################################################
|
69
|
+
|
70
|
+
def self.description
|
71
|
+
"Releases a version in your JIRA project"
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.details
|
75
|
+
"Use this action to release a version in JIRA"
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.available_options
|
79
|
+
[
|
80
|
+
FastlaneCore::ConfigItem.new(key: :url,
|
81
|
+
env_name: "FL_JIRA_UTIL_SITE",
|
82
|
+
description: "URL for Jira instance",
|
83
|
+
type: String,
|
84
|
+
verify_block: proc do |value|
|
85
|
+
UI.user_error!("No url for Jira given, pass using `url: 'url'`") unless value and !value.empty?
|
86
|
+
end),
|
87
|
+
FastlaneCore::ConfigItem.new(key: :username,
|
88
|
+
env_name: "FL_JIRA_UTIL_USERNAME",
|
89
|
+
description: "Username for JIRA instance",
|
90
|
+
type: String,
|
91
|
+
verify_block: proc do |value|
|
92
|
+
UI.user_error!("No username given, pass using `username: 'jira_user'`") unless value and !value.empty?
|
93
|
+
end),
|
94
|
+
FastlaneCore::ConfigItem.new(key: :password,
|
95
|
+
env_name: "FL_JIRA_UTIL_PASSWORD",
|
96
|
+
description: "Password for Jira",
|
97
|
+
type: String,
|
98
|
+
verify_block: proc do |value|
|
99
|
+
UI.user_error!("No password given, pass using `password: 'T0PS3CR3T'`") unless value and !value.empty?
|
100
|
+
end),
|
101
|
+
FastlaneCore::ConfigItem.new(key: :project_name,
|
102
|
+
env_name: "FL_RELEASE_JIRA_VERSION_PROJECT_NAME",
|
103
|
+
description: "Project ID for the JIRA project. E.g. the short abbreviation in the JIRA ticket tags",
|
104
|
+
type: String,
|
105
|
+
optional: true,
|
106
|
+
conflicting_options: [:project_id],
|
107
|
+
conflict_block: proc do |value|
|
108
|
+
UI.user_error!("You can't use 'project_name' and '#{project_id}' options in one run")
|
109
|
+
end,
|
110
|
+
verify_block: proc do |value|
|
111
|
+
UI.user_error!("No Project ID given, pass using `project_id: 'PROJID'`") unless value and !value.empty?
|
112
|
+
end),
|
113
|
+
FastlaneCore::ConfigItem.new(key: :project_id,
|
114
|
+
env_name: "FL_RELEASE_JIRA_VERSION_PROJECT_ID",
|
115
|
+
description: "Project ID for the JIRA project. E.g. the short abbreviation in the JIRA ticket tags",
|
116
|
+
type: String,
|
117
|
+
optional: true,
|
118
|
+
conflicting_options: [:project_name],
|
119
|
+
conflict_block: proc do |value|
|
120
|
+
UI.user_error!("You can't use 'project_id' and '#{project_name}' options in one run")
|
121
|
+
end,
|
122
|
+
verify_block: proc do |value|
|
123
|
+
UI.user_error!("No Project ID given, pass using `project_id: 'PROJID'`") unless value and !value.empty?
|
124
|
+
end),
|
125
|
+
FastlaneCore::ConfigItem.new(key: :name,
|
126
|
+
env_name: "FL_JIRA_UTIL_RELEASE_VERSION_NAME",
|
127
|
+
description: "The name of the version. E.g. 1.0.0",
|
128
|
+
type: String,
|
129
|
+
verify_block: proc do |value|
|
130
|
+
UI.user_error!("No version name given, pass using `name: '1.0.0'`") unless value and !value.empty?
|
131
|
+
end),
|
132
|
+
FastlaneCore::ConfigItem.new(key: :new_name,
|
133
|
+
env_name: "FL_JIRA_UTIL_RELEASE_VERSION_NEW_NAME",
|
134
|
+
description: "The new name of the version. It'll be released and renamed. E.g. 1.0.0",
|
135
|
+
type: String,
|
136
|
+
optional: true),
|
137
|
+
FastlaneCore::ConfigItem.new(key: :release_date,
|
138
|
+
env_name: "FL_JIRA_UTIL_RELEASE_VERSION_RELEASE_DATE",
|
139
|
+
description: "The date this version ended on",
|
140
|
+
type: String,
|
141
|
+
is_string: true,
|
142
|
+
optional: true,
|
143
|
+
default_value: Date.today.to_s)
|
144
|
+
]
|
145
|
+
end
|
146
|
+
|
147
|
+
def self.output
|
148
|
+
[
|
149
|
+
['RELEASE_JIRA_VERSION_VERSION_ID', 'The versionId for the newly released JIRA project version']
|
150
|
+
]
|
151
|
+
end
|
152
|
+
|
153
|
+
def self.return_value
|
154
|
+
'The versionId for the newly release JIRA project version'
|
155
|
+
end
|
156
|
+
|
157
|
+
def self.authors
|
158
|
+
["https://github.com/SandyChapman"]
|
159
|
+
end
|
160
|
+
|
161
|
+
def self.is_supported?(platform)
|
162
|
+
true
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
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 JiraUtilHelper
|
8
|
+
# class methods that you define here become available in your action
|
9
|
+
# as `Helper::JiraUtilHelper.your_method`
|
10
|
+
#
|
11
|
+
def self.show_message
|
12
|
+
UI.message("Hello from the jira_util plugin helper!")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,191 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fastlane-plugin-jira_util
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- '%q{Alexey Martynov}'
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-11-21 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.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.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: '%q{alexeyn.martynov@gmail.com}'
|
155
|
+
executables: []
|
156
|
+
extensions: []
|
157
|
+
extra_rdoc_files: []
|
158
|
+
files:
|
159
|
+
- LICENSE
|
160
|
+
- README.md
|
161
|
+
- lib/fastlane/plugin/jira_util.rb
|
162
|
+
- lib/fastlane/plugin/jira_util/actions/create_jira_issue.rb
|
163
|
+
- lib/fastlane/plugin/jira_util/actions/create_jira_version.rb
|
164
|
+
- lib/fastlane/plugin/jira_util/actions/release_jira_version.rb
|
165
|
+
- lib/fastlane/plugin/jira_util/helper/jira_util_helper.rb
|
166
|
+
- lib/fastlane/plugin/jira_util/version.rb
|
167
|
+
homepage: https://github.com/alexeyn-martynov/fastlane-plugin-jira_versions
|
168
|
+
licenses:
|
169
|
+
- MIT
|
170
|
+
metadata: {}
|
171
|
+
post_install_message:
|
172
|
+
rdoc_options: []
|
173
|
+
require_paths:
|
174
|
+
- lib
|
175
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - '>='
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '0'
|
180
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
181
|
+
requirements:
|
182
|
+
- - '>='
|
183
|
+
- !ruby/object:Gem::Version
|
184
|
+
version: '0'
|
185
|
+
requirements: []
|
186
|
+
rubyforge_project:
|
187
|
+
rubygems_version: 2.6.14
|
188
|
+
signing_key:
|
189
|
+
specification_version: 4
|
190
|
+
summary: '%q{Create JIRA issues and manage versions with this plugin}'
|
191
|
+
test_files: []
|