community.general.gitlab_milestone 模块 – 创建/更新/删除属于项目或组的 GitLab 里程碑

注意

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

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

要安装它,请使用:ansible-galaxy collection install community.general。您需要进一步的要求才能使用此模块,请参阅 要求 获取详细信息。

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

community.general 8.3.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 证书捆绑包。

group

字符串

组的路径。需要此项或 project

milestones

列表 / elements=字典

表示 gitlab 项目或组里程碑的字典列表。

默认值: []

description

字符串

里程碑的描述。

due_date

字符串

里程碑截止日期,格式为 YYYY-MM-DD。

start_date

字符串

里程碑开始日期,格式为 YYYY-MM-DD。

title

字符串 / 必需

里程碑的名称。

project

字符串

项目的路径和名称。需要此项或 group

purge

布尔值

设置为 true 时,删除任务中未提及的所有里程碑。

选项

  • false ← (默认)

  • true

state

字符串

创建或删除里程碑。

选项

  • "present" ← (默认)

  • "absent"

validate_certs

布尔值

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

选项

  • false

  • true ← (默认)

属性

属性

支持

描述

check_mode

支持: 完整

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

diff_mode

支持:

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

示例

# same project's task can be executed for group
- name: Create one milestone
  community.general.gitlab_milestone:
    api_url: https://gitlab.com
    api_token: secret_access_token
    project: "group1/project1"
    milestones:
      - title: milestone_one
        start_date: "2024-01-04"
    state: present

- name: Create many group milestones
  community.general.gitlab_milestone:
    api_url: https://gitlab.com
    api_token: secret_access_token
    group: "group1"
    milestones:
      - title: milestone_one
        start_date: "2024-01-04"
        description: this is a milestone
        due_date: "2024-02-04"
      - title: milestone_two
    state: present

- name: Create many project milestones
  community.general.gitlab_milestone:
    api_url: https://gitlab.com
    api_token: secret_access_token
    project: "group1/project1"
    milestones:
      - title: milestone_one
        start_date: "2024-01-04"
        description: this is a milestone
        due_date: "2024-02-04"
      - title: milestone_two
    state: present

- name: Set or update some milestones
  community.general.gitlab_milestone:
    api_url: https://gitlab.com
    api_token: secret_access_token
    project: "group1/project1"
    milestones:
      - title: milestone_one
        start_date: "2024-05-04"
    state: present

- name: Add milestone in check mode
  community.general.gitlab_milestone:
    api_url: https://gitlab.com
    api_token: secret_access_token
    project: "group1/project1"
    milestones:
      - title: milestone_one
        start_date: "2024-05-04"
    check_mode: true

- name: Delete milestone
  community.general.gitlab_milestone:
    api_url: https://gitlab.com
    api_token: secret_access_token
    project: "group1/project1"
    milestones:
      - title: milestone_one
    state: absent

- name: Purge all milestones
  community.general.gitlab_milestone:
    api_url: https://gitlab.com
    api_token: secret_access_token
    project: "group1/project1"
    purge: true

- name: Delete many milestones
  community.general.gitlab_milestone:
    api_url: https://gitlab.com
    api_token: secret_access_token
    project: "group1/project1"
    state: absent
    milestones:
      - title: milestone-abc123
      - title: milestone-two

返回值

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

描述

milestones

字典

包含已添加、更新、删除或存在的里程碑的四个列表。

返回: 成功

已添加

列表 / 元素=字符串

已创建的里程碑的列表。

返回: 始终

示例: ["abcd", "milestone-one"]

已删除

列表 / 元素=字符串

已删除的里程碑的列表。

返回: 始终

示例: ["defg", "new-milestone"]

未触及

列表 / 元素=字符串

存在的里程碑的列表。

返回: 始终

示例: ["defg", "new-milestone"]

已更新

列表 / 元素=字符串

其值已设置的预先存在的里程碑的列表。

返回: 始终

示例: ["defg", "new-milestone"]

milestones_obj

字典

API 对象。

返回: 成功

作者

  • Gabriele Pongelli (@gpongelli)