From 26c3f6cea0d5f5fa951bf56319e95262531e54f4 Mon Sep 17 00:00:00 2001 From: Clement Verna Date: Feb 23 2018 18:38:47 +0000 Subject: Handle new PR messages Signed-off-by: Clement Verna --- diff --git a/app/webhooks.py b/app/webhooks.py index f5342d6..06ade0c 100644 --- a/app/webhooks.py +++ b/app/webhooks.py @@ -90,7 +90,7 @@ def openshift_jenkins(): topic = request.headers.get('X-Pagure-Topic') log.debug('Webhook topic received : {}'.format(topic)) - if topic == 'git.receive': + if topic in ['git.receive', 'pagure.pull-request.new']: server = Jenkins(current_app.config['JENKINS_URL']) jobname = current_app.config['JENKINS_JOB'] @@ -101,11 +101,16 @@ def openshift_jenkins(): json_data = request.get_json(force=True, silent=True) data = { - 'cause': 'Pagure CI', 'REPO': repo_url, - 'BRANCH': json_data['msg']['branch'] } + if topic == 'pagure.pull-request.new': + data['cause'] = json_data['msg']['pullrequest']['id'] + data['BRANCH'] = json_data['msg']['pullrequest']['branch_from'] + + else: + data['BRANCH'] = json_data['msg']['branch'] + try: server.build_job( name=jobname,