community.general.gitlab_merge_request module – Create, update, or delete GitLab merge requests
Note
This module is part of the community.general collection (version 7.5.2).
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
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.general.gitlab_merge_request
.
New in community.general 7.1.0
Synopsis
Creates a merge request if it does not exist.
When a single merge request does exist, it will be updated if the provided parameters are different.
When a single merge request does exist and
state=absent
, the merge request will be deleted.When multiple merge requests are detected, the task fails.
Existing merge requests are matched based on
title
,source_branch
,target_branch
, andstate_filter
filters.
Requirements
The below requirements are needed on the host that executes this module.
Python >= 2.7
python-gitlab >= 2.3.0
requests (Python library https://pypi.org/project/requests/)
Parameters
Parameter |
Comments |
---|---|
GitLab CI job token for logging in. |
|
GitLab OAuth token for logging in. |
|
The password to use for authentication against the API |
|
GitLab access token with API permissions. |
|
The resolvable endpoint for the API |
|
The username to use for authentication against the API |
|
Comma separated list of assignees usernames omitting Set to empty string to unassign all assignees. |
|
A description for the merge request. Gets overridden by a content of file specified at |
|
A path of file containing merge request’s description. Accepts MarkDown formatted files. |
|
Comma separated list of label names. Default: |
|
The path or name of the project. |
|
Flag indicating if a merge request should remove the source branch when merging. Choices:
|
|
Comma separated list of reviewers usernames omitting Set to empty string to unassign all reviewers. |
|
Merge request’s source branch. Ignored while updating existing merge request. |
|
Create or delete merge request. Choices:
|
|
Filter specifying state of merge requests while searching. Choices:
|
|
Merge request’s target branch. |
|
A title for the merge request. |
|
Whether or not to validate SSL certs when supplying a https endpoint. Choices:
|
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full |
Can run in |
|
Support: none |
Will return details on what has changed (or possibly needs changing in |
Examples
- name: Create Merge Request from branch1 to branch2
community.general.gitlab_merge_request:
api_url: https://gitlab.com
api_token: secret_access_token
project: "group1/project1"
source_branch: branch1
target_branch: branch2
title: "Ansible demo MR"
description: "Demo MR description"
labels: "Ansible,Demo"
state_filter: "opened"
remove_source_branch: True
state: present
- name: Delete Merge Request from branch1 to branch2
community.general.gitlab_merge_request:
api_url: https://gitlab.com
api_token: secret_access_token
project: "group1/project1"
source_branch: branch1
target_branch: branch2
title: "Ansible demo MR"
state_filter: "opened"
state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
API object. Returned: success |
|
Success or failure message. Returned: always Sample: |