community.general.gitlab_branch (8.5.0) — module

Create or delete a branch

| "added in version" 4.2.0 of community.general"

Authors: paytroff (@paytroff)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

This module allows to create or delete branches.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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

Inputs

    
state:
    choices:
    - present
    - absent
    default: present
    description:
    - Create or delete branch.
    type: str

branch:
    description:
    - The name of the branch that needs to be created.
    required: true
    type: str

api_url:
    description:
    - The resolvable endpoint for the API.
    type: str

ca_path:
    description:
    - The CA certificates bundle to use to verify GitLab server certificate.
    type: str
    version_added: 8.1.0
    version_added_collection: community.general

project:
    description:
    - The path or name of the project.
    required: true
    type: str

api_token:
    description:
    - GitLab access token with API permissions.
    type: str

ref_branch:
    description:
    - Reference branch to create from.
    - This must be specified if O(state=present).
    type: str

api_password:
    description:
    - The password to use for authentication against the API.
    type: str

api_username:
    description:
    - The username to use for authentication against the API.
    type: str

api_job_token:
    description:
    - GitLab CI job token for logging in.
    type: str
    version_added: 4.2.0
    version_added_collection: community.general

validate_certs:
    default: true
    description:
    - Whether or not to validate SSL certs when supplying a HTTPS endpoint.
    type: bool

api_oauth_token:
    description:
    - GitLab OAuth token for logging in.
    type: str
    version_added: 4.2.0
    version_added_collection: community.general