Sha256: b435123830add7aea56c82ff2f3eda7a86d52a831b03b142410973d64cde19f7
Contents?: true
Size: 1.64 KB
Versions: 1
Compression:
Stored size: 1.64 KB
Contents
# frozen_string_literal: true require "date" require "jira-ruby" module Groundskeeper # Wraps an interface to Jira. class Jira attr_reader :client, :prefix ISSUE_PATTERN = "%s-\\d+" # Wraps the jira-ruby Client class. class JiraClient attr_reader :client def initialize @client = JIRA::Client.new( username: ENV["JIRA_USERNAME"], password: ENV["JIRA_PASSWORD"], site: ENV["JIRA_SITE"], context_path: "", auth_type: :basic, read_timeout: 120 ) end def create_version(name:, prefix:) client.Version .build .save(name: name, project: prefix) end def add_version_to_issue(issue_id:, version_name:) client.Issue .find(issue_id) .save(update: { fixVersions: [{ add: { name: version_name } }] }) end end def self.build(prefix) new( prefix: prefix, client: JiraClient.new ) end def initialize(client: nil, prefix: nil) @prefix = prefix @client = client end # Returns the list of Jira issues found in a set of commit messages. def included_issues(changes) issue_expression = /#{format(ISSUE_PATTERN, prefix)}/ changes.map { |change| change.scan(issue_expression) }.flatten.compact end def create_remote_version(name) client.create_version(name: name, prefix: prefix) end def add_version_to_remote_issues(name, issue_ids) issue_ids.each do |issue_id| client.add_version_to_issue(issue_id: issue_id, version_name: name) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
groundskeeper-bitcore-0.1.1 | lib/groundskeeper/jira.rb |