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
#!/usr/bin/python3
import os
import sys
import gitlab
project = sys.argv[1]
api = gitlab.Gitlab('https://salsa.debian.org', os.environ['SALSA_TOKEN'])
p = api.projects.get(project)
print('Setting up KGB and emails-on-push for project %s (%s)' % (project, p.id))
for hook in p.hooks.list():
if hook.url.startswith('http://kgb.debian.net'):
print('KGB hook %s (%s) already exists, skipping setup' % (hook.id, hook.url))
break
else:
print('added hook',
p.hooks.create({
'url': 'http://kgb.debian.net:9418/webhook/?channel=%s&network=oftc&private=1&use_color=1&use_irc_notices=1&squash_threshold=3&always_squash_outside_dir=debian' % 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 = p.services.get('emails-on-push')
if emailservice.active:
print('emails-on-push already enabled, skipping')
else:
emailservice.recipients = 'debian-x@lists.debian.org'
emailservice.send_from_committer_email = True
emailservice.save()
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