Class: Groundskeeper::Jira
- Inherits:
-
Object
- Object
- Groundskeeper::Jira
- Defined in:
- lib/groundskeeper/jira.rb
Overview
Wraps an interface to Jira.
Defined Under Namespace
Classes: JiraClient
Constant Summary collapse
- JIRA_USERNAME_KEY =
"JIRA_USERNAME"- JIRA_PASSWORD_KEY =
"JIRA_PASSWORD"- JIRA_SITE_KEY =
"JIRA_SITE"- DEPLOY_TO_STAGING =
"Deploy to Staging"- DELIVER =
"Deliver"- TRANSITION_IDS =
{ DEPLOY_TO_STAGING => 231, DELIVER => 201 }.freeze
- ISSUE_PATTERN =
"%s-\\d+"
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
Class Method Summary collapse
Instance Method Summary collapse
- #add_version_to_remote_issues(name, issue_ids) ⇒ Object
- #create_remote_version(name) ⇒ Object
- #credentials? ⇒ Boolean
-
#fetch_issues_by_fix_version(version) ⇒ Object
:nocov:.
-
#included_issues(changes) ⇒ Object
Returns the list of Jira issues found in a set of commit messages.
-
#initialize(client: nil, prefix: nil) ⇒ Jira
constructor
A new instance of Jira.
- #transition_remote_issues(transition_type, issue_ids) ⇒ Object
Constructor Details
#initialize(client: nil, prefix: nil) ⇒ Jira
Returns a new instance of Jira.
83 84 85 86 |
# File 'lib/groundskeeper/jira.rb', line 83 def initialize(client: nil, prefix: nil) @prefix = prefix @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
19 20 21 |
# File 'lib/groundskeeper/jira.rb', line 19 def client @client end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
19 20 21 |
# File 'lib/groundskeeper/jira.rb', line 19 def prefix @prefix end |
Class Method Details
.build(prefix) ⇒ Object
76 77 78 79 80 81 |
# File 'lib/groundskeeper/jira.rb', line 76 def self.build(prefix) new( prefix: prefix, client: JiraClient.new ) end |
Instance Method Details
#add_version_to_remote_issues(name, issue_ids) ⇒ Object
109 110 111 112 113 |
# File 'lib/groundskeeper/jira.rb', line 109 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 |
#create_remote_version(name) ⇒ Object
105 106 107 |
# File 'lib/groundskeeper/jira.rb', line 105 def create_remote_version(name) client.create_version(name: name, prefix: prefix) end |
#credentials? ⇒ Boolean
88 89 90 91 92 |
# File 'lib/groundskeeper/jira.rb', line 88 def credentials? ENV[JIRA_USERNAME_KEY].present? && ENV[JIRA_PASSWORD_KEY].present? && ENV[JIRA_SITE_KEY].present? end |
#fetch_issues_by_fix_version(version) ⇒ Object
:nocov:
125 126 127 |
# File 'lib/groundskeeper/jira.rb', line 125 def fetch_issues_by_fix_version(version) client.fetch_issues_by_fix_version(version: version) end |
#included_issues(changes) ⇒ Object
Returns the list of Jira issues found in a set of commit messages.
95 96 97 98 99 100 101 102 103 |
# File 'lib/groundskeeper/jira.rb', line 95 def included_issues(changes) issue_expression = /#{format(ISSUE_PATTERN, prefix)}/ changes .map { |change| change.scan(issue_expression) } .flatten .compact .sort end |
#transition_remote_issues(transition_type, issue_ids) ⇒ Object
115 116 117 118 119 120 121 122 |
# File 'lib/groundskeeper/jira.rb', line 115 def transition_remote_issues(transition_type, issue_ids) issue_ids.each do |issue_id| client.transition_issue( issue_id: issue_id, transition_id: TRANSITION_IDS[transition_type] ) end end |