Commit 365634e2 authored by Julien Cristau's avatar Julien Cristau

Add a script for kgb/emails-on-push setup

Tries to be idempotent, as far as possible, rather than overwriting
existing setup.
parent 42de0ea9
import os
import sys
import gitlab
project = sys.argv[1]
api = gitlab.Gitlab('', os.environ['SALSA_TOKEN'])
p = api.projects.get(project)
print('Setting up KGB and emails-on-push for project %s (%s)' % (project,
for hook in p.hooks.list():
if hook.url.startswith(''):
print('KGB hook %s (%s) already exists, skipping setup' % (, hook.url))
print('added hook',
'url': '' % channel,
'push_events': 'yes',
'issues_events': 'yes',
'merge_requests_events': 'yes',
'tag_push_events': 'yes',
'note_events': 'yes',
'job_events': 'yes',
'pipeline_events': 'yes',
'wiki_events': 'yes',
'enable_ssl_verification': 'yes',
emailservice ='emails-on-push')
print('emails-on-push already enabled, skipping')
emailservice.recipients = ''
emailservice.send_from_committer_email = True
print('emails-on-push service enabled')
Markdown is supported
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