community.general.gitlab_project_badge (8.5.0) — module

Manage project badges on GitLab Server

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

Authors: Guillaume MARTINEZ (@Lunik)

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 add and remove badges to/from a project.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add a badge to a GitLab Project
  community.general.gitlab_project_badge:
    api_url: 'https://example.gitlab.com'
    api_token: 'Your-Private-Token'
    project: projectname
    state: present
    link_url: 'https://example.gitlab.com/%{project_path}'
    image_url: 'https://example.gitlab.com/%{project_path}/badges/%{default_branch}/pipeline.svg'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove a badge from a GitLab Project
  community.general.gitlab_project_badge:
    api_url: 'https://example.gitlab.com'
    api_token: 'Your-Private-Token'
    project: projectname
    state: absent
    link_url: 'https://example.gitlab.com/%{project_path}'
    image_url: 'https://example.gitlab.com/%{project_path}/badges/%{default_branch}/pipeline.svg'

Inputs

    
state:
    choices:
    - present
    - absent
    default: present
    description:
    - State of the badge in the project.
    - On V(present), it adds a badge to a GitLab project.
    - On V(absent), it removes a badge from a GitLab project.
    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 name (or full path) of the GitLab project the badge is added to/removed from.
    required: true
    type: str

link_url:
    description:
    - The URL associated with the badge.
    required: true
    type: str

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

image_url:
    description:
    - The image URL of the badge.
    - A badge is identified by this URL.
    required: true
    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

Outputs

badge:
  description: The badge information.
  returned: when O(state=present)
  sample:
    id: 1
    image_url: https://shields.io/my/badge
    kind: project
    link_url: http://example.com/ci_status.svg?project=%{project_path}&ref=%{default_branch}
    rendered_image_url: https://shields.io/my/badge
    rendered_link_url: http://example.com/ci_status.svg?project=example-org/example-project&ref=master
  type: dict