From 0945e5c8cef3f89318991fc127536e5a8c8eacb4 Mon Sep 17 00:00:00 2001 From: Clement Verna Date: Feb 28 2018 20:18:20 +0000 Subject: Add support for closing PR message. We send Jenkins a STATUS property with the following status OPEN, MERGED or CLOSED. Signed-off-by: Clement Verna --- diff --git a/app/webhooks.py b/app/webhooks.py index f07d2f0..32cc36b 100644 --- a/app/webhooks.py +++ b/app/webhooks.py @@ -104,7 +104,7 @@ def openshift_jenkins(): log.debug('Webhook received : Repo: {}, Topic: {}'.format(project_fullname, topic)) if topic in ['git.receive', 'pull-request.new', - 'pull-request.comment.added']: + 'pull-request.comment.added', 'pull-request.closed']: server = Jenkins(current_app.config['JENKINS_URL']) @@ -132,6 +132,10 @@ def openshift_jenkins(): data['PR'] = json_data['msg']['pullrequest']['id'] data['BRANCH'] = json_data['msg']['pullrequest']['branch_from'] + if json_data['msg'].get('merged') is not None: + data['STATUS'] = 'MERGED' if json_data['msg']['merged'] else 'CLOSED' + else: + data['STATUS'] = 'OPEN' jobname = current_app.config['JENKINS_JOB_PR'] else: