fastlane-plugin-jira_issue_features 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0671d5c18e202bfeb43dae09bc1203b5eb58338885aff02f243978bc4162e0c7
4
+ data.tar.gz: f6ad8b9934d968615c557b5bc0f583b34a10d8ddaf0db77de34c0d01ed0b6f2d
5
+ SHA512:
6
+ metadata.gz: e0b7f6159d472278501ab43023e29131dd952f030859582e5f1b6113ff4159006aeaa967a2cfffd9c17fd22fcd4bee57caa2aef8763291098532451523bcff9a
7
+ data.tar.gz: 96bfa4226859f225fdc8e5ae13cc42601b5ccdfe517c5b53c5e727b7094b36aeb4e8650b2d4be1296309b337e9e9e880b36e921d1b66dc2623d73eca8767ee6e
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Bilal Durnagol <bilaldurnagol@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,52 @@
1
+ # jira_issue_features 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_issue_features)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-jira_issue_features`, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin jira_issue_features
11
+ ```
12
+
13
+ ## About jira_issue_features
14
+
15
+ Automates Jira's features.
16
+
17
+ **Note to author:** Add a more detailed description about this plugin here. If your plugin contains multiple actions, make sure to mention them here.
18
+
19
+ ## 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` and `bundle exec fastlane test`.
22
+
23
+ **Note to author:** Please set up a sample project to make it easy for users to explore what your plugin does. Provide everything that is necessary to try out the plugin in this project (including a sample Xcode/Android project if necessary)
24
+
25
+ ## Run tests for this plugin
26
+
27
+ To run both the tests, and code style validation, run
28
+
29
+ ```
30
+ rake
31
+ ```
32
+
33
+ To automatically fix many of the styling issues, use
34
+ ```
35
+ rubocop -a
36
+ ```
37
+
38
+ ## Issues and Feedback
39
+
40
+ For any other issues and feedback about this plugin, please submit it to this repository.
41
+
42
+ ## Troubleshooting
43
+
44
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
45
+
46
+ ## Using _fastlane_ Plugins
47
+
48
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
49
+
50
+ ## About _fastlane_
51
+
52
+ _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,182 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/jira_issue_features_helper'
3
+ require 'net/http'
4
+ require 'json'
5
+ require 'base64'
6
+
7
+ module Fastlane
8
+ module Actions
9
+ class JiraIssueFeaturesAction < Action
10
+ def self.run(params)
11
+ jira_base_url = params[:jira_base_url]
12
+ issue_id = params[:issue_id]
13
+ target_column_name = params[:target_column_name]
14
+ email = params[:email]
15
+ api_token = params[:api_token]
16
+ comment = params[:comment]
17
+ # Step 1: Transition List Retrieval
18
+ UI.message("Fetching available transitions for issue '#{issue_id}'...")
19
+ transitions = fetch_transitions(jira_base_url, issue_id, email, api_token)
20
+
21
+ # Step 2: Find Transition ID for Target Column
22
+ transition_id = find_transition_id(transitions, target_column_name)
23
+
24
+ if transition_id.nil?
25
+ UI.error("Target column '#{target_column_name}' not found in transitions for issue '#{issue_id}'.")
26
+ return
27
+ end
28
+
29
+ UI.message("Found transition ID '#{transition_id}' for column '#{target_column_name}'.")
30
+
31
+ # Step 3: Execute Transition
32
+ UI.message("Moving issue '#{issue_id}' to column '#{target_column_name}'...")
33
+ execute_transition(jira_base_url, issue_id, transition_id, email, api_token)
34
+ if params[:comment].to_s.strip.empty?
35
+ UI.important("No comment provided. Skipping comment addition for issue '#{params[:issue_id]}'.")
36
+ else
37
+ UI.message("Adding comment to issue '#{params[:issue_id]}'...")
38
+ add_comment_to_issue(jira_base_url, issue_id, comment, email, api_token)
39
+ end
40
+ UI.success("Issue '#{issue_id}' successfully moved to '#{target_column_name}'!")
41
+ end
42
+
43
+ # Fetch available transitions for the issue
44
+ def self.fetch_transitions(base_url, issue_id, email, api_token)
45
+ uri = URI("#{base_url}/rest/api/3/issue/#{issue_id}/transitions")
46
+ response = make_request(uri, email, api_token, :get)
47
+ return JSON.parse(response.body)['transitions'] if response.is_a?(Net::HTTPSuccess)
48
+
49
+ UI.error("Failed to fetch transitions: #{response.body}")
50
+ exit
51
+ end
52
+
53
+ # Add a comment to the specified JIRA issue
54
+ def self.add_comment_to_issue(base_url, issue_id, comment, email, api_token)
55
+ uri = URI("#{base_url}/rest/api/3/issue/#{issue_id}/comment")
56
+ body = {
57
+ "body" => {
58
+ "content" => [
59
+ {
60
+ "content" => [
61
+ {
62
+ "text" => comment,
63
+ "type" => "text",
64
+ "marks": [
65
+ {
66
+ "type": "textColor",
67
+ "attrs": {
68
+ "color": "#FF0000"
69
+ }
70
+ },
71
+ {
72
+ "type": "strong"
73
+ },
74
+ {
75
+ "type": "underline"
76
+ }
77
+ ]
78
+
79
+ }
80
+ ],
81
+ "type" => "paragraph"
82
+ }
83
+ ],
84
+ "type" => "doc",
85
+ "version" => 1
86
+ }
87
+ }.to_json
88
+ response = make_request(uri, email, api_token, :post, body)
89
+
90
+ if response.is_a?(Net::HTTPSuccess)
91
+ UI.success("Comment added to issue '#{issue_id}': #{comment}")
92
+ else
93
+ UI.error("Failed to add comment to issue '#{issue_id}': #{response.body}")
94
+ exit
95
+ end
96
+ end
97
+
98
+ # Find the transition ID for the target column
99
+ def self.find_transition_id(transitions, column_name)
100
+ transitions.find { |t| t['name'].casecmp(column_name).zero? }&.dig('id')
101
+ end
102
+
103
+ # Execute the transition for the issue
104
+ def self.execute_transition(base_url, issue_id, transition_id, email, api_token)
105
+ uri = URI("#{base_url}/rest/api/3/issue/#{issue_id}/transitions")
106
+ body = { transition: { id: transition_id } }.to_json
107
+ response = make_request(uri, email, api_token, :post, body)
108
+
109
+ unless response.is_a?(Net::HTTPSuccess)
110
+ UI.error("Failed to move issue: #{response.body}")
111
+ exit
112
+ end
113
+ end
114
+
115
+ # Make HTTP request with proper headers
116
+ def self.make_request(uri, email, api_token, method, body = nil)
117
+ request = method == :get ? Net::HTTP::Get.new(uri) : Net::HTTP::Post.new(uri)
118
+ request['Authorization'] = "Basic #{Base64.strict_encode64("#{email}:#{api_token}")}"
119
+ request['Content-Type'] = 'application/json'
120
+ request.body = body if body
121
+
122
+ Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
123
+ http.request(request)
124
+ end
125
+ end
126
+
127
+ def self.description
128
+ "Automates Jira's features."
129
+ end
130
+
131
+ def self.authors
132
+ ["Bilal Durnagol"]
133
+ end
134
+
135
+ def self.return_value
136
+ # If your method provides a return value, you can describe here what it does
137
+ end
138
+
139
+ def self.details
140
+ # Optional:
141
+ "Changing columns, adding comments, reading title, etc..."
142
+ end
143
+
144
+ def self.available_options
145
+ [
146
+ FastlaneCore::ConfigItem.new(key: :jira_base_url,
147
+ description: "Base URL of your JIRA instance (e.g., https://your-domain.atlassian.net)",
148
+ optional: false,
149
+ type: String),
150
+ FastlaneCore::ConfigItem.new(key: :issue_id,
151
+ description: "The JIRA issue ID (e.g., IOS-405)",
152
+ optional: false,
153
+ type: String),
154
+ FastlaneCore::ConfigItem.new(key: :target_column_name,
155
+ description: "The target column name (e.g., REVIEW)",
156
+ optional: false,
157
+ type: String),
158
+ FastlaneCore::ConfigItem.new(key: :email,
159
+ description: "Your JIRA account email",
160
+ optional: false,
161
+ type: String),
162
+ FastlaneCore::ConfigItem.new(key: :api_token,
163
+ description: "Your JIRA API token",
164
+ optional: false,
165
+ type: String),
166
+ FastlaneCore::ConfigItem.new(key: :comment,
167
+ description: "Comment to add to the JIRA issue (optional)",
168
+ optional: true,
169
+ type: String)
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,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 JiraIssueFeaturesHelper
8
+ # class methods that you define here become available in your action
9
+ # as `Helper::JiraIssueFeaturesHelper.your_method`
10
+ #
11
+ def self.show_message
12
+ UI.message("Hello from the jira_issue_features plugin helper!")
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module JiraIssueFeatures
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/jira_issue_features/version'
2
+
3
+ module Fastlane
4
+ module JiraIssueFeatures
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::JiraIssueFeatures.all_classes.each do |current|
15
+ require current
16
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-jira_issue_features
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Bilal Durnagol
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-01-02 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: bilaldurnagol@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - LICENSE
20
+ - README.md
21
+ - lib/fastlane/plugin/jira_issue_features.rb
22
+ - lib/fastlane/plugin/jira_issue_features/actions/jira_issue_features_action.rb
23
+ - lib/fastlane/plugin/jira_issue_features/helper/jira_issue_features_helper.rb
24
+ - lib/fastlane/plugin/jira_issue_features/version.rb
25
+ homepage: https://github.com/bilaldurnagol/fastlane-plugin-jira_issue_features
26
+ licenses:
27
+ - MIT
28
+ metadata:
29
+ rubygems_mfa_required: 'true'
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '2.6'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubygems_version: 3.0.3.1
46
+ signing_key:
47
+ specification_version: 4
48
+ summary: Automates Jiras features.
49
+ test_files: []