From 94be732351692e3418d88e73f4c1570513e86c1c Mon Sep 17 00:00:00 2001 From: Pierre GINDRAUD Date: Sun, 15 Dec 2019 23:08:10 +0100 Subject: [PATCH] Handle push_events_branch_filter in gitlab hooks (#60039) * Handle push_events_branch_filter in gitlab hooks * Update doc of push_events_branch_filter option in gitlab hooks * Ensure default empty value for push_events_branch_filter * scm/gitlab_hook : Update version_added to 2.10 --- .../modules/source_control/gitlab/gitlab_hook.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/ansible/modules/source_control/gitlab/gitlab_hook.py b/lib/ansible/modules/source_control/gitlab/gitlab_hook.py index 7552e7fa392..bd9c969db6f 100644 --- a/lib/ansible/modules/source_control/gitlab/gitlab_hook.py +++ b/lib/ansible/modules/source_control/gitlab/gitlab_hook.py @@ -58,6 +58,11 @@ options: - Trigger hook on push events. type: bool default: yes + push_events_branch_filter: + description: + - Branch name of wildcard to trigger hook on push events + type: str + version_added: "2.10" issues_events: description: - Trigger hook on issues events. @@ -200,6 +205,7 @@ class GitLabHook(object): hook = self.createHook(project, { 'url': hook_url, 'push_events': options['push_events'], + 'push_events_branch_filter': options['push_events_branch_filter'], 'issues_events': options['issues_events'], 'merge_requests_events': options['merge_requests_events'], 'tag_push_events': options['tag_push_events'], @@ -213,6 +219,7 @@ class GitLabHook(object): else: changed, hook = self.updateHook(self.hookObject, { 'push_events': options['push_events'], + 'push_events_branch_filter': options['push_events_branch_filter'], 'issues_events': options['issues_events'], 'merge_requests_events': options['merge_requests_events'], 'tag_push_events': options['tag_push_events'], @@ -300,6 +307,7 @@ def main(): project=dict(type='str', required=True), hook_url=dict(type='str', required=True), push_events=dict(type='bool', default=True), + push_events_branch_filter=dict(type='str', default=''), issues_events=dict(type='bool', default=False), merge_requests_events=dict(type='bool', default=False), tag_push_events=dict(type='bool', default=False), @@ -330,6 +338,7 @@ def main(): project_identifier = module.params['project'] hook_url = module.params['hook_url'] push_events = module.params['push_events'] + push_events_branch_filter = module.params['push_events_branch_filter'] issues_events = module.params['issues_events'] merge_requests_events = module.params['merge_requests_events'] tag_push_events = module.params['tag_push_events'] @@ -364,6 +373,7 @@ def main(): if state == 'present': if gitlab_hook.createOrUpdateHook(project, hook_url, { "push_events": push_events, + "push_events_branch_filter": push_events_branch_filter, "issues_events": issues_events, "merge_requests_events": merge_requests_events, "tag_push_events": tag_push_events,