community.general.gitlab_hook – Manages GitLab project hooks.
Note
This plugin is part of the community.general collection (version 3.8.3).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.general
.
To use it in a playbook, specify: community.general.gitlab_hook
.
Requirements
The below requirements are needed on the host that executes this module.
python >= 2.7
python-gitlab python module
Parameters
Parameter |
Comments |
---|---|
The password to use for authentication against the API |
|
GitLab token for logging in. |
|
The resolvable endpoint for the API |
|
The username to use for authentication against the API |
|
The url that you want GitLab to post to, this is used as the primary key for updates and deletion. |
|
Whether GitLab will do SSL verification when triggering the hook. Choices:
|
|
Trigger hook on issues events. Choices:
|
|
Trigger hook on job events. Choices:
|
|
Trigger hook on merge requests events. Choices:
|
|
Trigger hook on note events or when someone adds a comment. Choices:
|
|
Trigger hook on pipeline events. Choices:
|
|
Id or Full path of the project in the form of group/name. |
|
Trigger hook on push events. Choices:
|
|
Branch name of wildcard to trigger hook on push events |
|
When When Choices:
|
|
Trigger hook on tag push events. Choices:
|
|
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. |
|
Whether or not to validate SSL certs when supplying a https endpoint. Choices:
|
|
Trigger hook on wiki events. Choices:
|
Examples
- name: "Adding a project hook"
community.general.gitlab_hook:
api_url: https://gitlab.example.com/
api_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
hook_validate_certs: no
token: "my-super-secret-token-that-my-ci-server-will-check"
- name: "Delete the previous hook"
community.general.gitlab_hook:
api_url: https://gitlab.example.com/
api_token: "{{ access_token }}"
project: "my_group/my_project"
hook_url: "https://my-ci-server.example.com/gitlab-hook"
state: absent
- name: "Delete a hook by numeric project id"
community.general.gitlab_hook:
api_url: https://gitlab.example.com/
api_token: "{{ access_token }}"
project: 10
hook_url: "https://my-ci-server.example.com/gitlab-hook"
state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
the error message returned by the GitLab API Returned: failed Sample: “400: path is already in use” |
|
API object Returned: always |
|
Success or failure message Returned: always Sample: “Success” |
|
json parsed response from the server Returned: always |
Authors
Marcus Watkins (@marwatk)
Guillaume Martinez (@Lunik)