community.general.gitlab_project_badge 模块 – 在 GitLab 服务器上管理项目徽章

注意

此模块是 community.general 集合 (版本 10.1.0) 的一部分。

如果您使用的是 ansible 包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install community.general。您需要其他要求才能使用此模块,有关详细信息,请参阅 要求

要在 playbook 中使用它,请指定:community.general.gitlab_project_badge

community.general 6.1.0 中的新增功能

概要

  • 此模块允许向项目添加和删除徽章。

要求

执行此模块的主机需要以下要求。

参数

参数

注释

api_job_token

字符串

在 community.general 4.2.0 中添加

用于登录的 GitLab CI 作业令牌。

api_oauth_token

字符串

在 community.general 4.2.0 中添加

用于登录的 GitLab OAuth 令牌。

api_password

字符串

用于针对 API 进行身份验证的密码。

api_token

字符串

具有 API 权限的 GitLab 访问令牌。

api_url

字符串

API 的可解析端点。

api_username

字符串

用于针对 API 进行身份验证的用户名。

ca_path

字符串

在 community.general 8.1.0 中添加

用于验证 GitLab 服务器证书的 CA 证书包。

image_url

字符串 / 必需

徽章的图像 URL。

徽章以此 URL 标识。

字符串 / 必需

与徽章关联的 URL。

project

字符串 / 必需

添加或删除徽章的 GitLab 项目的名称(或完整路径)。

state

字符串

项目中徽章的状态。

present 上,它会将徽章添加到 GitLab 项目。

absent 上,它会从 GitLab 项目中删除徽章。

选项

  • "present" ← (默认)

  • "absent"

validate_certs

布尔值

是否在提供 HTTPS 端点时验证 SSL 证书。

选项

  • false

  • true ← (默认)

属性

属性

支持

描述

check_mode

支持:完全支持

可以在 check_mode 下运行并返回更改状态预测,而无需修改目标。

diff_mode

支持:不支持

在差异模式下,将返回有关已更改内容(或可能需要在 check_mode 中更改的内容)的详细信息。

示例

- 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'

- 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'

返回值

常见返回值已在此处记录 此处,以下是此模块特有的字段

描述

badge

字典

徽章信息。

返回:state=present

示例:{"id": 1, "image_url": "https://shieldsio.npmjs.net.cn/my/badge", "kind": "project", "link_url": "http://example.com/ci_status.svg?project=%{project_path}&ref=%{default_branch}", "rendered_image_url": "https://shieldsio.npmjs.net.cn/my/badge", "rendered_link_url": "http://example.com/ci_status.svg?project=example-org/example-project&ref=master"}

作者

  • Guillaume MARTINEZ (@Lunik)