community.general.gitlab_branch module – Create or delete a branch
Note
This module is part of the community.general collection (version 9.5.1).
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_branch
.
New in community.general 4.2.0
Synopsis
This module allows to create or delete branches.
Requirements
The below requirements are needed on the host that executes this module.
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. |
|
The name of the branch that needs to be created. |
|
The CA certificates bundle to use to verify GitLab server certificate. |
|
The path or name of the project. |
|
Reference branch to create from. This must be specified if |
|
Create or delete branch. Choices:
|
|
Whether or not to validate SSL certs when supplying a HTTPS endpoint. Choices:
|
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: none |
Can run in |
|
Support: none |
Will return details on what has changed (or possibly needs changing in |
Examples
- name: Create branch branch2 from main
community.general.gitlab_branch:
api_url: https://gitlab.com
api_token: secret_access_token
project: "group1/project1"
branch: branch2
ref_branch: main
state: present
- name: Delete branch branch2
community.general.gitlab_branch:
api_url: https://gitlab.com
api_token: secret_access_token
project: "group1/project1"
branch: branch2
state: absent