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
-
#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.
75 76 77 78 |
# File 'lib/groundskeeper/jira.rb', line 75 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
68 69 70 71 72 73 |
# File 'lib/groundskeeper/jira.rb', line 68 def self.build(prefix) new( prefix: prefix, client: JiraClient.new ) end |
Instance Method Details
#add_version_to_remote_issues(name, issue_ids) ⇒ Object
97 98 99 100 101 |
# File 'lib/groundskeeper/jira.rb', line 97 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
93 94 95 |
# File 'lib/groundskeeper/jira.rb', line 93 def create_remote_version(name) client.create_version(name: name, prefix: prefix) end |
#credentials? ⇒ Boolean
80 81 82 83 84 |
# File 'lib/groundskeeper/jira.rb', line 80 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
112 113 114 |
# File 'lib/groundskeeper/jira.rb', line 112 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.
87 88 89 90 91 |
# File 'lib/groundskeeper/jira.rb', line 87 def included_issues(changes) issue_expression = /#{format(ISSUE_PATTERN, prefix)}/ changes.map { |change| change.scan(issue_expression) }.flatten.compact end |
#transition_remote_issues(transition_type, issue_ids) ⇒ Object
103 104 105 106 107 108 109 110 |
# File 'lib/groundskeeper/jira.rb', line 103 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 |