ansible / ansible.builtin / v2.7.18 / module / gitlab_hooks Manages GitLab project hooks. | "added in version" 2.6 of ansible.builtin" Authors: Marcus Watkins (@marwatk) preview | supported by communityansible.builtin.gitlab_hooks (v2.7.18) — module
pip
Install with pip install ansible==2.7.18
Adds, updates and removes project hooks
# Example creating a new project hook - gitlab_hooks: api_url: https://gitlab.example.com/api access_token: "{{ access_token }}" project: "my_group/my_project" hook_url: "https://my-ci-server.example.com/gitlab-hook" state: present push_events: yes enable_ssl_verification: no token: "my-super-secret-token-that-my-ci-server-will-check"
# Update the above hook to add tag pushes - gitlab_hooks: api_url: https://gitlab.example.com/api access_token: "{{ access_token }}" project: "my_group/my_project" hook_url: "https://my-ci-server.example.com/gitlab-hook" state: present push_events: yes tag_push_events: yes enable_ssl_verification: no token: "my-super-secret-token-that-my-ci-server-will-check"
# Delete the previous hook - gitlab_hooks: api_url: https://gitlab.example.com/api access_token: "{{ access_token }}" project: "my_group/my_project" hook_url: "https://my-ci-server.example.com/gitlab-hook" state: absent
# Delete a hook by numeric project id - gitlab_hooks: api_url: https://gitlab.example.com/api access_token: "{{ access_token }}" project: 10 hook_url: "https://my-ci-server.example.com/gitlab-hook" state: absent
state: choices: - present - absent default: present description: - When C(present) the hook will be updated to match the input or created if it doesn't exist. When C(absent) it will be deleted if it exists. required: true token: description: - Secret token to validate hook messages at the receiver. - If this is present it will always result in a change as it cannot be retrieved from GitLab. - Will show up in the X-Gitlab-Token HTTP request header required: false api_url: description: - GitLab API url, e.g. https://gitlab.example.com/api required: true project: description: - Numeric project id or name of project in the form of group/name required: true hook_url: description: - The url that you want GitLab to post to, this is used as the primary key for updates and deletion. required: true job_events: default: 'no' description: - Trigger hook on job events type: bool note_events: default: 'no' description: - Trigger hook on note events type: bool push_events: default: 'yes' description: - Trigger hook on push events type: bool access_token: description: - The oauth key provided by GitLab. One of access_token or private_token is required. See https://docs.gitlab.com/ee/api/oauth2.html required: false issues_events: default: 'no' description: - Trigger hook on issues events type: bool private_token: description: - Personal access token to use. One of private_token or access_token is required. See https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html required: false pipeline_events: default: 'no' description: - Trigger hook on pipeline events type: bool tag_push_events: default: 'no' description: - Trigger hook on tag push events type: bool wiki_page_events: default: 'no' description: - Trigger hook on wiki events type: bool merge_requests_events: default: 'no' description: - Trigger hook on merge requests events type: bool enable_ssl_verification: default: 'no' description: - Whether GitLab will do SSL verification when triggering the hook type: bool
error: description: the error message returned by the Gitlab API returned: failed sample: '400: key is already in use' type: string msg: description: Success or failure message returned: always sample: Success type: string previous_version: description: object describing the state prior to this task returned: changed type: dict result: description: json parsed response from the server returned: always type: dict