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
This commit is contained in:
Pierre GINDRAUD 2019-12-15 23:08:10 +01:00 committed by ansibot
parent 8165ce6144
commit 94be732351

View file

@ -58,6 +58,11 @@ options:
- Trigger hook on push events. - Trigger hook on push events.
type: bool type: bool
default: yes 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: issues_events:
description: description:
- Trigger hook on issues events. - Trigger hook on issues events.
@ -200,6 +205,7 @@ class GitLabHook(object):
hook = self.createHook(project, { hook = self.createHook(project, {
'url': hook_url, 'url': hook_url,
'push_events': options['push_events'], 'push_events': options['push_events'],
'push_events_branch_filter': options['push_events_branch_filter'],
'issues_events': options['issues_events'], 'issues_events': options['issues_events'],
'merge_requests_events': options['merge_requests_events'], 'merge_requests_events': options['merge_requests_events'],
'tag_push_events': options['tag_push_events'], 'tag_push_events': options['tag_push_events'],
@ -213,6 +219,7 @@ class GitLabHook(object):
else: else:
changed, hook = self.updateHook(self.hookObject, { changed, hook = self.updateHook(self.hookObject, {
'push_events': options['push_events'], 'push_events': options['push_events'],
'push_events_branch_filter': options['push_events_branch_filter'],
'issues_events': options['issues_events'], 'issues_events': options['issues_events'],
'merge_requests_events': options['merge_requests_events'], 'merge_requests_events': options['merge_requests_events'],
'tag_push_events': options['tag_push_events'], 'tag_push_events': options['tag_push_events'],
@ -300,6 +307,7 @@ def main():
project=dict(type='str', required=True), project=dict(type='str', required=True),
hook_url=dict(type='str', required=True), hook_url=dict(type='str', required=True),
push_events=dict(type='bool', default=True), push_events=dict(type='bool', default=True),
push_events_branch_filter=dict(type='str', default=''),
issues_events=dict(type='bool', default=False), issues_events=dict(type='bool', default=False),
merge_requests_events=dict(type='bool', default=False), merge_requests_events=dict(type='bool', default=False),
tag_push_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'] project_identifier = module.params['project']
hook_url = module.params['hook_url'] hook_url = module.params['hook_url']
push_events = module.params['push_events'] push_events = module.params['push_events']
push_events_branch_filter = module.params['push_events_branch_filter']
issues_events = module.params['issues_events'] issues_events = module.params['issues_events']
merge_requests_events = module.params['merge_requests_events'] merge_requests_events = module.params['merge_requests_events']
tag_push_events = module.params['tag_push_events'] tag_push_events = module.params['tag_push_events']
@ -364,6 +373,7 @@ def main():
if state == 'present': if state == 'present':
if gitlab_hook.createOrUpdateHook(project, hook_url, { if gitlab_hook.createOrUpdateHook(project, hook_url, {
"push_events": push_events, "push_events": push_events,
"push_events_branch_filter": push_events_branch_filter,
"issues_events": issues_events, "issues_events": issues_events,
"merge_requests_events": merge_requests_events, "merge_requests_events": merge_requests_events,
"tag_push_events": tag_push_events, "tag_push_events": tag_push_events,