Class: Fastlane::Actions::JiraMoveTicketsAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::JiraMoveTicketsAction
- Defined in:
- lib/fastlane/plugin/jira_update/actions/jira_move_tickets_action.rb
Documentation collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .category ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .example_code ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .return_type ⇒ Object
- .return_value ⇒ Object
Class Method Summary collapse
Class Method Details
.authors ⇒ Object
115 116 117 |
# File 'lib/fastlane/plugin/jira_update/actions/jira_move_tickets_action.rb', line 115 def self. ["Flop Butylkin"] end |
.available_options ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/fastlane/plugin/jira_update/actions/jira_move_tickets_action.rb', line 74 def self. [ FastlaneCore::ConfigItem.new(key: :url, env_name: "FL_JIRA_SITE", description: "URL for Jira instance", verify_block: proc do |value| UI.user_error!("No url for Jira given") if value.to_s.length == 0 end), FastlaneCore::ConfigItem.new(key: :username, env_name: "FL_JIRA_USERNAME", description: "Username for Jira instance", verify_block: proc do |value| UI.user_error!("No username") if value.to_s.length == 0 end), FastlaneCore::ConfigItem.new(key: :password, env_name: "FL_JIRA_PASSWORD", description: "Password or api token for Jira", sensitive: true, verify_block: proc do |value| UI.user_error!("No password") if value.to_s.length == 0 end), FastlaneCore::ConfigItem.new(key: :ticket, env_name: "FL_JIRA_TICKET", description: "Jira ticket id", type: String, optional: true, default_value: nil), FastlaneCore::ConfigItem.new(key: :tickets, env_name: "FL_JIRA_TICKETS", description: "Jira tickets ids array", type: Array, optional: true, default_value: nil), FastlaneCore::ConfigItem.new(key: :target, env_name: "FL_JIRA_TARGET", description: "Target status for Jira tickets", type: String, default_value: "Closed") ] end |
.category ⇒ Object
139 140 141 |
# File 'lib/fastlane/plugin/jira_update/actions/jira_move_tickets_action.rb', line 139 def self.category :misc end |
.description ⇒ Object
58 59 60 |
# File 'lib/fastlane/plugin/jira_update/actions/jira_move_tickets_action.rb', line 58 def self.description "Jira update actions" end |
.details ⇒ Object
62 63 64 |
# File 'lib/fastlane/plugin/jira_update/actions/jira_move_tickets_action.rb', line 62 def self.details "Update Jira tickets" end |
.example_code ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/fastlane/plugin/jira_update/actions/jira_move_tickets_action.rb', line 123 def self.example_code [ ' gym slack(message: "Done") jira_move_tickets( url: "https://jira.yourdomain.com", username: "Username", password: "Password", ticket: "ABC-123", target: "Done" ) ' ] end |
.is_supported?(platform) ⇒ Boolean
119 120 121 |
# File 'lib/fastlane/plugin/jira_update/actions/jira_move_tickets_action.rb', line 119 def self.is_supported?(platform) true end |
.return_type ⇒ Object
70 71 72 |
# File 'lib/fastlane/plugin/jira_update/actions/jira_move_tickets_action.rb', line 70 def self.return_type :hash end |
.return_value ⇒ Object
66 67 68 |
# File 'lib/fastlane/plugin/jira_update/actions/jira_move_tickets_action.rb', line 66 def self.return_value "Hash where keys are Jira ticket IDs and values results of the action" end |
.run(params) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/fastlane/plugin/jira_update/actions/jira_move_tickets_action.rb', line 4 def self.run(params) Actions.verify_gem!('jira-ruby') require 'jira-ruby' client = JIRA::Client.new( username: params[:username], password: params[:password], site: params[:url], context_path: '', auth_type: :basic ) issues = {} issues[params[:ticket]] = "" if params[:ticket] params[:tickets].each { |ticket| issues[ticket] = "" } if params[:tickets] target = params[:target] UI.("JIRA tickets to move: '#{issues.keys}' to '#{target}'") issues.each_key do |ticket| # puts "Moving ticket #{ticket}" result = "" begin issue = client.Issue.find(ticket) transition = issue.transitions.build available_transitions = issue.transitions.all.map { |t| { id: t.id, name: t.name } } # puts "Available transitions: #{available_transitions}" target_transition = available_transitions.find { |t| t[:name].casecmp(target).zero? } if target_transition transition.save!("transition" => { "id" => target_transition[:id] }) result = "Success '#{target}'" else result = "Can't move to '#{target}'" end rescue StandardError => e UI.important("Failed to fetch issue #{ticket}: #{e.}") result = "Ticket not found" end issues[ticket] = result end UI.("JIRA tickets updated: '#{issues}'") return issues end |