From b65483b1c41bd2fc1dc23dfdae7dbd63f1edba20 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Aug 09 2016 13:54:35 +0000 Subject: Send notification to the CI service to kick off the build Let's kick the CI build when: * A new PR is created * An open PR gets a notification (rebase/new commits) And of course, only when there is a CI service configured for the project --- diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index 293f3c8..3a8193f 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -864,6 +864,15 @@ def add_pull_request_comment(session, request, commit, tree_id, filename, 'notification': notification, })) + # Send notification to the CI server, if the comment added was a + # notification and the PR is still open + if notification and request.status == 'Open' \ + and request.project.ci_hook and PAGURE_CI: + REDIS.publish('pagure.ci', json.dumps({ + 'ci_type': request.project.ci_hook.type_ci.type, + 'pr': request.to_json(public=True, with_comments=False) + })) + pagure.lib.notify.log( request.project, topic='pull-request.comment.added', @@ -1226,6 +1235,13 @@ def new_pull_request(session, branch_from, redis=REDIS, ) + # Send notification to the CI server + if request.project.ci_hook and PAGURE_CI: + REDIS.publish('pagure.ci', json.dumps({ + 'ci_type': request.project.ci_hook.type_ci.type, + 'pr': request.to_json(public=True, with_comments=False) + })) + return request