community.general.gitlab_milestone module – Creates/updates/deletes GitLab Milestones belonging to project or group

Note

This module is part of the community.general collection (version 8.6.7).

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_milestone.

New in community.general 8.3.0

Synopsis

  • When a milestone does not exist, it will be created.

  • When a milestone does exist, its value will be updated when the values are different.

  • Milestones can be purged.

Requirements

The below requirements are needed on the host that executes this module.

Parameters

Parameter

Comments

api_job_token

string

added in community.general 4.2.0

GitLab CI job token for logging in.

api_oauth_token

string

added in community.general 4.2.0

GitLab OAuth token for logging in.

api_password

string

The password to use for authentication against the API.

api_token

string

GitLab access token with API permissions.

api_url

string

The resolvable endpoint for the API.

api_username

string

The username to use for authentication against the API.

ca_path

string

added in community.general 8.1.0

The CA certificates bundle to use to verify GitLab server certificate.

group

string

The path of the group. Either this or project is required.

milestones

list / elements=dictionary

A list of dictionaries that represents gitlab project’s or group’s milestones.

Default: []

description

string

Milestone’s description.

due_date

string

Milestone due date in YYYY-MM-DD format.

start_date

string

Milestone start date in YYYY-MM-DD format.

title

string / required

The name of the milestone.

project

string

The path and name of the project. Either this or group is required.

purge

boolean

When set to true, delete all milestone which are not mentioned in the task.

Choices:

  • false ← (default)

  • true

state

string

Create or delete milestone.

Choices:

  • "present" ← (default)

  • "absent"

validate_certs

boolean

Whether or not to validate SSL certs when supplying a HTTPS endpoint.

Choices:

  • false

  • true ← (default)

Attributes

Attribute

Support

Description

check_mode

Support: full

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: none

Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode.

Examples

# 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

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

milestones

dictionary

Four lists of the milestones which were added, updated, removed or exist.

Returned: success

added

list / elements=string

A list of milestones which were created.

Returned: always

Sample: ["abcd", "milestone-one"]

removed

list / elements=string

A list of milestones which were deleted.

Returned: always

Sample: ["defg", "new-milestone"]

untouched

list / elements=string

A list of milestones which exist.

Returned: always

Sample: ["defg", "new-milestone"]

updated

list / elements=string

A list pre-existing milestones whose values have been set.

Returned: always

Sample: ["defg", "new-milestone"]

milestones_obj

dictionary

API object.

Returned: success

Authors

  • Gabriele Pongelli (@gpongelli)