Class: Fastlane::Actions::JiraGetTicketAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::JiraGetTicketAction
- Defined in:
- lib/fastlane/plugin/jira_update/actions/jira_get_ticket.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
95 96 97 |
# File 'lib/fastlane/plugin/jira_update/actions/jira_get_ticket.rb', line 95 def self. ["Flop Butylkin"] end |
.available_options ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/fastlane/plugin/jira_update/actions/jira_get_ticket.rb', line 65 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) ] end |
.category ⇒ Object
113 114 115 |
# File 'lib/fastlane/plugin/jira_update/actions/jira_get_ticket.rb', line 113 def self.category :misc end |
.description ⇒ Object
49 50 51 |
# File 'lib/fastlane/plugin/jira_update/actions/jira_get_ticket.rb', line 49 def self.description "Jira ticket comment replace action" end |
.details ⇒ Object
53 54 55 |
# File 'lib/fastlane/plugin/jira_update/actions/jira_get_ticket.rb', line 53 def self.details "Replace Jira ticket comment" end |
.example_code ⇒ Object
103 104 105 106 107 108 109 110 111 |
# File 'lib/fastlane/plugin/jira_update/actions/jira_get_ticket.rb', line 103 def self.example_code [ ' jira_get_ticket( ticket: "APP-132", ) ' ] end |
.is_supported?(platform) ⇒ Boolean
99 100 101 |
# File 'lib/fastlane/plugin/jira_update/actions/jira_get_ticket.rb', line 99 def self.is_supported?(platform) true end |
.return_type ⇒ Object
61 62 63 |
# File 'lib/fastlane/plugin/jira_update/actions/jira_get_ticket.rb', line 61 def self.return_type :hash end |
.return_value ⇒ Object
57 58 59 |
# File 'lib/fastlane/plugin/jira_update/actions/jira_get_ticket.rb', line 57 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 |
# File 'lib/fastlane/plugin/jira_update/actions/jira_get_ticket.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 ) ticket = params[:ticket] UI.("JIRA ticket id: '#{ticket}'") begin issue = client.Issue.find(ticket) rescue StandardError => e UI.important("Failed to fetch issue #{ticket}: #{e.}") UI.error!("Failed to fetch issue #{ticket}: #{e.}") if fail_if_not_found result = "Ticket not found" end # Convert the issue to a hash only with the fields we need issue_hash = { id: issue.id, key: issue.key, summary: issue.summary, description: issue.description, status: issue.status.name, assignee: issue.assignee.displayName, reporter: issue.reporter.displayName, created: issue.created, updated: issue.updated } UI.("JIRA ticket found: '#{issue_hash[:key]}'") return issue_hash end |