Julien Cristau pushed to branch master at X Strike Force / debian / xsf-tools
Commits:
-
365634e2
by Julien Cristau at 2018-07-03T16:11:09+02:00
1 changed file:
Changes:
| 1 |
+#!/usr/bin/python3
|
|
| 2 |
+ |
|
| 3 |
+import os
|
|
| 4 |
+import sys
|
|
| 5 |
+import gitlab
|
|
| 6 |
+ |
|
| 7 |
+project = sys.argv[1]
|
|
| 8 |
+ |
|
| 9 |
+api = gitlab.Gitlab('https://salsa.debian.org', os.environ['SALSA_TOKEN'])
|
|
| 10 |
+p = api.projects.get(project)
|
|
| 11 |
+print('Setting up KGB and emails-on-push for project %s (%s)' % (project, p.id))
|
|
| 12 |
+ |
|
| 13 |
+for hook in p.hooks.list():
|
|
| 14 |
+ if hook.url.startswith('http://kgb.debian.net'):
|
|
| 15 |
+ print('KGB hook %s (%s) already exists, skipping setup' % (hook.id, hook.url))
|
|
| 16 |
+ break
|
|
| 17 |
+else:
|
|
| 18 |
+ print('added hook',
|
|
| 19 |
+ p.hooks.create({
|
|
| 20 |
+ '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,
|
|
| 21 |
+ 'push_events': 'yes',
|
|
| 22 |
+ 'issues_events': 'yes',
|
|
| 23 |
+ 'merge_requests_events': 'yes',
|
|
| 24 |
+ 'tag_push_events': 'yes',
|
|
| 25 |
+ 'note_events': 'yes',
|
|
| 26 |
+ 'job_events': 'yes',
|
|
| 27 |
+ 'pipeline_events': 'yes',
|
|
| 28 |
+ 'wiki_events': 'yes',
|
|
| 29 |
+ 'enable_ssl_verification': 'yes',
|
|
| 30 |
+ })
|
|
| 31 |
+ )
|
|
| 32 |
+ |
|
| 33 |
+emailservice = p.services.get('emails-on-push')
|
|
| 34 |
+if emailservice.active:
|
|
| 35 |
+ print('emails-on-push already enabled, skipping')
|
|
| 36 |
+else:
|
|
| 37 |
+ emailservice.recipients = 'debian-x@lists.debian.org'
|
|
| 38 |
+ emailservice.send_from_committer_email = True
|
|
| 39 |
+ emailservice.save()
|
|
| 40 |
+ print('emails-on-push service enabled')
|