blob: f39caf911dd73425815768c095cafb5100defa1e (
plain)
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
|
require 'gitlab'
require 'date'
# TODO: Move config to yaml
my_group_path = 'leap'
Gitlab.configure do |config|
# API endpoint URL, default
config.endpoint = ENV['GITLAB_ENDPOINT']
# User's private token or OAuth2 access token
config.private_token = ENV['GITLAB_TOKEN']
end
pr_widget_data_id = 'gitlab-merge-requests'
SCHEDULER.every '10m', :first_in => 0 do |job|
my_group = Gitlab.groups(:search => my_group_path).find do |group|
group.path == my_group_path
end
projects = Gitlab.group(my_group.id).projects.map do |proj|
{ :id => proj['id'], :name => proj['name'] }
end
open_merge_requests = projects.inject([]) { |merges, proj|
Gitlab.merge_requests(proj[:id], :state => 'opened').each do |request|
puts proj[:name] + ': ' + request.title
merges.push({
title: request.title,
repo: proj[:name],
updated_at: DateTime.parse(request.updated_at).strftime("%b %-d %Y, %l:%m %p"),
creator: "@" + request.author.username
})
end
merges
}
send_event(pr_widget_data_id, { header: "Open Merge Requests", merges: open_merge_requests })
end
|