class Fastlane::Helper::CerberusHelper::JiraHelper

Public Class Methods

new(host:, username:, password:, context_path:, disable_ssl_verification:, jira_client_helper: nil) click to toggle source
# File lib/fastlane/plugin/cerberus/helper/cerberus_helper.rb, line 25
def initialize(host:, username:, password:, context_path:, disable_ssl_verification:, jira_client_helper: nil)
  @host = host
  @context_path = context_path

  jira_client_helper ||= JiraClientHelper.client(
    host: host,
    username: username,
    password: password,
    context_path: context_path,
    disable_ssl_verification: disable_ssl_verification
  )
  @client = jira_client_helper
end

Public Instance Methods

add_comment(comment:, issues:) click to toggle source
# File lib/fastlane/plugin/cerberus/helper/cerberus_helper.rb, line 51
def add_comment(comment:, issues:)
  return if issues.to_a.empty?

  issues.each do |issue|
    begin
      issue.comments.build.save({ 'body' => comment })
    rescue => e
      UI.important("Jira Client: Failed to comment on issues - #{issue.key}")
      UI.important("Jira Client: Reason - #{e.message}")
    end
  end
end
get(issues:) click to toggle source
# File lib/fastlane/plugin/cerberus/helper/cerberus_helper.rb, line 39
def get(issues:)
  return [] if issues.to_a.empty?

  begin
    @client.Issue.jql("KEY IN (#{issues.join(',')})", fields: [:key, :summary], validate_query: false)
  rescue => e
    UI.important('Jira Client: Failed to get issue.')
    UI.important("Jira Client: Reason - #{e.message}")
    []
  end
end
url(issue:) click to toggle source
# File lib/fastlane/plugin/cerberus/helper/cerberus_helper.rb, line 64
def url(issue:)
  [@host, @context_path, 'browse', issue.key].reject(&:empty?).join('/')
end