-
Notifications
You must be signed in to change notification settings - Fork 8
/
jira.rb
59 lines (47 loc) · 1.01 KB
/
jira.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
require 'jira-ruby'
class Jira
def self.set_config(config)
@config = config
end
def self.issue(id)
api.Issue.find(id)
end
def self.issue_url(issue_id)
"#{config.site}/browse/#{issue_id}"
end
def self.update_summary(issue, summary)
issue.save({'fields' => { 'summary' => summary}})
end
def self.add_remote_link(issue, label, url)
return if issue.remotelink.all.find { |link| link.attrs.dig('object', 'title') }
link = issue.remotelink.build
link.save(
object: {
url: url,
title: label
}
)
end
def self.active_sprints
api.Agile.get_sprints(config.board, state: 'active')
end
def self.find_sprint(id)
api.Sprint.find(id)
end
private
def self.api
@client ||= JIRA::Client.new({
username: config.user,
password: config.password,
site: config.site,
context_path: '',
auth_type: :basic,
})
end
def self.config
@config
end
def self.project(id)
api.Project.find(id)
end
end