fastlane-plugin-jira_update_tickets 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: dd9ac1bffe726acaa304d2a07b3667c3ea360e2063345439dbbf29289dfbb2c2
4
+ data.tar.gz: b0cd7336a8887f6105248c73d0fdf9f9590acda39e38944138dd7e4352f956c7
5
+ SHA512:
6
+ metadata.gz: 4ffd36400007806f2a13baf0367d4b33e582868357e8c8339f67bf0c7556a840cd99844dcccc22f67e0230f163749beb3bc11719d51f4e218b57c77557f6e883
7
+ data.tar.gz: 7f62369972bda3baf35a973922f32c7beced3b80281e69ccef9e429648c4035fbb2c8e83d111f9aa9ef6c1338571b719d215a8cefa03e1db03bb5a146e54a74b
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Luca Tagliabue <lu.tagliabue@reply.it>
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_update_tickets 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_update_tickets)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-jira_update_tickets`, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin jira_update_tickets
11
+ ```
12
+
13
+ ## About jira_update_tickets
14
+
15
+ Update status and fix version of provided jira tickets
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,144 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fastlane/action'
4
+ require 'fastlane_core'
5
+
6
+ module Fastlane
7
+ module Actions
8
+ class JiraUpdateTicketsAction < Action
9
+ # rubocop:disable Metrics/PerceivedComplexity
10
+ # rubocop:disable Metrics/CyclomaticComplexity
11
+ # rubocop:disable Metrics/MethodLength
12
+ def self.run(params)
13
+ Actions.verify_gem!('jira-ruby')
14
+ require 'jira-ruby'
15
+
16
+ tickets = params[:tickets]
17
+
18
+ tickets = [] if tickets.instance_of?(NilClass)
19
+
20
+ exit(0) if tickets.empty?
21
+
22
+ client = JIRA::Client.new(
23
+ username: params[:username],
24
+ password: params[:password],
25
+ site: params[:url],
26
+ context_path: '',
27
+ auth_type: :basic
28
+ )
29
+
30
+ next_transition_name = params[:next_transition_name]
31
+ fix_version = params[:fix_version]
32
+
33
+ tickets.each do |ticket|
34
+ issue = client.Issue.find(ticket)
35
+
36
+ next if issue.instance_of?(NilClass)
37
+
38
+ unless next_transition_name.instance_of?(NilClass)
39
+ available_transitions = client.Transition.all(issue: issue)
40
+
41
+ available_transitions = [] if available_transitions.instance_of?(NilClass)
42
+
43
+ next_transition = available_transitions.find do |transition|
44
+ transition.to.name == next_transition_name
45
+ end
46
+
47
+ unless next_transition.instance_of?(NilClass)
48
+ # ticket can go to desired status
49
+ transition = issue.transitions.build
50
+ transition.save!('transition' => { 'id' => next_transition.id })
51
+ end
52
+ end
53
+
54
+ next if fix_version.instance_of?(NilClass)
55
+
56
+ issue.save({
57
+ 'fields' => {
58
+ 'fixVersions' => [{
59
+ 'name' => fix_version
60
+ }]
61
+ }
62
+ })
63
+ end
64
+ end
65
+ # rubocop:enable Metrics/PerceivedComplexity
66
+ # rubocop:enable Metrics/CyclomaticComplexity
67
+ # rubocop:enable Metrics/MethodLength
68
+
69
+ def self.description
70
+ 'Update status and fix version of provided jira tickets'
71
+ end
72
+
73
+ def self.authors
74
+ ['Luca Tagliabue']
75
+ end
76
+
77
+ def self.return_value
78
+ # If your method provides a return value, you can describe here what it does
79
+ end
80
+
81
+ def self.details
82
+ 'The aim of this plugin is to help jira tickets managment setting fix version updating the status'
83
+ end
84
+
85
+ # rubocop:disable Metrics/MethodLength
86
+ def self.available_options
87
+ [
88
+ FastlaneCore::ConfigItem.new(key: :url,
89
+ env_name: 'FL_JIRA_SITE',
90
+ description: 'URL for Jira instance',
91
+ sensitive: true,
92
+ type: String,
93
+ verify_block: ->(value) { verify_option(key: 'url', value: value) }),
94
+ FastlaneCore::ConfigItem.new(key: :username,
95
+ env_name: 'FL_JIRA_USERNAME',
96
+ description: 'Username for Jira instance',
97
+ sensitive: true,
98
+ type: String,
99
+ verify_block: ->(value) { verify_option(key: 'username', value: value) }),
100
+ FastlaneCore::ConfigItem.new(key: :password,
101
+ env_name: 'FL_JIRA_PASSWORD',
102
+ description: 'Password or api token for Jira',
103
+ sensitive: true,
104
+ type: String,
105
+ verify_block: ->(value) { verify_option(key: 'password', value: value) }),
106
+ FastlaneCore::ConfigItem.new(key: :tickets,
107
+ description: 'Array of Strings. Each value is a JIRA ticket name',
108
+ type: Array,
109
+ verify_block: lambda { |value|
110
+ FastlaneCore::UI.user_error!("No value found for 'tickets'") if Array(value).empty?
111
+ }),
112
+ FastlaneCore::ConfigItem.new(key: :next_transition_name,
113
+ description: 'New transition name of the ticket',
114
+ type: String,
115
+ optional: true),
116
+ FastlaneCore::ConfigItem.new(key: :fix_version,
117
+ description: 'Fix version of the ticket',
118
+ type: String,
119
+ optional: true)
120
+ ]
121
+ end
122
+ # rubocop:enable Metrics/MethodLength
123
+
124
+ def self.verify_option(options)
125
+ FastlaneCore::UI.user_error!("No value found for '#{options[:key]}'") if options[:value].to_s.empty?
126
+ end
127
+
128
+ def self.example_code
129
+ [
130
+ 'jira_update_tickets(
131
+ url: "YOUR_URL_HERE",
132
+ username: "YOUR_USERNAME_HERE",
133
+ password: "YOUR_PASSWORD_HERE",
134
+ tickets: ["ISSUE-1"]
135
+ )'
136
+ ]
137
+ end
138
+
139
+ def self.is_supported?(_platform)
140
+ true
141
+ end
142
+ end
143
+ end
144
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fastlane
4
+ module Helper
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fastlane
4
+ module JiraUpdateTickets
5
+ VERSION = '0.1.0'
6
+ end
7
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fastlane/plugin/jira_update_tickets/version'
4
+
5
+ module Fastlane
6
+ module JiraUpdateTickets
7
+ # Return all .rb files inside the "actions" and "helper" directory
8
+ def self.all_classes
9
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
10
+ end
11
+ end
12
+ end
13
+
14
+ # By default we want to import all available actions and helpers
15
+ # A plugin can contain any number of actions and plugins
16
+ Fastlane::JiraUpdateTickets.all_classes.each do |current|
17
+ require current
18
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-jira_update_tickets
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Luca Tagliabue
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-03-21 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: lu.tagliabue@reply.it
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - LICENSE
20
+ - README.md
21
+ - lib/fastlane/plugin/jira_update_tickets.rb
22
+ - lib/fastlane/plugin/jira_update_tickets/actions/jira_update_tickets_action.rb
23
+ - lib/fastlane/plugin/jira_update_tickets/helper/jira_update_tickets_helper.rb
24
+ - lib/fastlane/plugin/jira_update_tickets/version.rb
25
+ homepage: https://github.com/lukluca/fastlane-plugin-jira_update_tickets
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.5.4
46
+ signing_key:
47
+ specification_version: 4
48
+ summary: Update status and fix version of provided jira tickets
49
+ test_files: []