Verified Commit 99f2535e authored by A. Wilcox's avatar A. Wilcox 🦊
Browse files

Add pipeline event support for GitLab

parent f46c188e
import asyncio
from emily.core import push_event, merge_event
from emily.core import push_event, merge_event, pipe_event
from emily.protocols.http import http_handle, HTTPProtocol
class GitLab:
......@@ -52,5 +52,15 @@ class GitLab:
yield from merge_event.call_async(project, merge_info)
return True
elif json['object_kind'] == 'pipeline':
pipe_info = {}
pipe_info['branch'] = json['object_attributes'].get('ref', 'Unknown')
pipe_info['status'] = json['object_attributes'].get('status')
pipe_info['id'] = json['object_attributes'].get('id')
project = request.match_info.get('grp', 'default') + '/' + \
request.match_info.get('project')
yield from pipe_event.call_async(project, pipe_info)
else:
return False
......@@ -38,6 +38,7 @@ class IRC:
def __init__(self, loop):
push_event.add(self.push)
merge_event.add(self.merge)
pipe_event.add(self.pipe)
myconf = config['irc']
self.networks = [network.strip()
......@@ -129,3 +130,14 @@ class IRC:
for channel in channels:
network, irc_chan = channel.split(':', 1)
self.network_instances[network].send('PRIVMSG', [irc_chan, msg])
def pipe(self, project, pipe):
channels = set(self.projects[project] +
self.projects[project.split('/', 1)[0] + '/*'] +
self.projects['*/*'])
msg = '\x02{}\x02: Pipeline #{} for branch \x02{}\x02 status: {}'
msg = msg.format(project, pipe['id'], pipe['branch'], pipe['status'])
for channel in channels:
network, irc_chan = channel.split(':', 1)
self.network_instances[network].send('PRIVMSG', [irc_chan, msg])
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment