class Fastlane::Actions::GetJiraIssueAction
Public Class Methods
available_options()
click to toggle source
# File lib/fastlane/plugin/jira_issue_details/actions/get_jira_issue.rb, line 36 def self.available_options [ FastlaneCore::ConfigItem.new(key: :username, env_name: "JIRA_ISSUE_DETAILS_USERNAME", description: "Your Jira Username", optional: false, type: String), FastlaneCore::ConfigItem.new(key: :api_token, env_name: "JIRA_ISSUE_DETAILS_API_TOKEN", description: "Your Jira API Token", optional: false, type: String), FastlaneCore::ConfigItem.new(key: :site, env_name: "JIRA_ISSUE_DETAILS_SITE", description: "Your Jira Site ('http://yourdomain.atlassian.net')", optional: false, type: String), FastlaneCore::ConfigItem.new(key: :issue_key, env_name: "JIRA_ISSUE_DETAILS_ISSUE_KEY", description: "Your Jira Issue Key(s). Separate with a single space ` ` to add more keys", optional: false, type: String) ] end
description()
click to toggle source
# File lib/fastlane/plugin/jira_issue_details/actions/get_jira_issue.rb, line 17 def self.description "Get the details for the given jira issue key(s)." end
details()
click to toggle source
# File lib/fastlane/plugin/jira_issue_details/actions/get_jira_issue.rb, line 32 def self.details "It utilises the `jira-ruby` gem to communicate with Jira and get the details of the Jira issue for the given key.\n\n(Currently only supports basic auth_type login)." end
is_supported?(platform)
click to toggle source
# File lib/fastlane/plugin/jira_issue_details/actions/get_jira_issue.rb, line 64 def self.is_supported?(platform) true end
return_value()
click to toggle source
# File lib/fastlane/plugin/jira_issue_details/actions/get_jira_issue.rb, line 25 def self.return_value single_key = "it returns a `Hash` containing the details of the jira issue for the given key, or `nil` if the issue key does not exists." multiple_key = "it returns a `Hash` of `key-Hash` pairs containing the details of the jira issue key, or `key-nil` pair if the issue key does not exists." "For single jira issue key, #{single_key} For multiple jira issue keys, #{multiple_key}" end
run(params)
click to toggle source
# File lib/fastlane/plugin/jira_issue_details/actions/get_jira_issue.rb, line 8 def self.run(params) input = get_input_from_env input = get_input_from(params) if is_exists?(params) return nil if is_nil_any(input) client = JIRA::Client.new(options_for_jira_client(input)) return get_issues_from(client, input) end
Private Class Methods
fetch_issue(key, client)
click to toggle source
# File lib/fastlane/plugin/jira_issue_details/actions/get_jira_issue.rb, line 116 def self.fetch_issue(key, client) begin return client.Issue.find(key).attrs rescue return nil end end
get_input_from(params)
click to toggle source
# File lib/fastlane/plugin/jira_issue_details/actions/get_jira_issue.rb, line 83 def self.get_input_from(params) { site: params[:site], username: params[:username], api_token: params[:api_token], issue_key: params[:issue_key] } end
get_input_from_env()
click to toggle source
# File lib/fastlane/plugin/jira_issue_details/actions/get_jira_issue.rb, line 70 def self.get_input_from_env { site: ENV['JIRA_ISSUE_DETAILS_SITE'], username: ENV['JIRA_ISSUE_DETAILS_USERNAME'], api_token: ENV['JIRA_ISSUE_DETAILS_API_TOKEN'], issue_key: ENV['JIRA_ISSUE_DETAILS_ISSUE_KEY'] } end
get_issues_from(client, input)
click to toggle source
# File lib/fastlane/plugin/jira_issue_details/actions/get_jira_issue.rb, line 107 def self.get_issues_from(client, input) issues = {} keys = input[:issue_key].split(" ") keys.each {|key| issues[key] = fetch_issue(key, client) } return issues[keys.first] if keys.count == 1 return issues end
is_exists?(params)
click to toggle source
# File lib/fastlane/plugin/jira_issue_details/actions/get_jira_issue.rb, line 79 def self.is_exists?(params) params && params[:site] && params[:username] && params[:api_token] && params[:issue_key] end
is_nil_any(input)
click to toggle source
# File lib/fastlane/plugin/jira_issue_details/actions/get_jira_issue.rb, line 92 def self.is_nil_any(input) input[:site].nil? || input[:username].nil? || input[:api_token].nil? || input[:issue_key].nil? end
options_for_jira_client(input)
click to toggle source
# File lib/fastlane/plugin/jira_issue_details/actions/get_jira_issue.rb, line 96 def self.options_for_jira_client(input) { username: input[:username], password: input[:api_token], context_path: "", auth_type: :basic, site: "#{input[:site]}:443/", rest_base_path: "/rest/api/3" } end