Use ProjectMilestone objects to manipulate milestones. The gitlab.Gitlab.project_milestones and Project.milestones manager objects provide helper functions.


List the milestones for a project:

milestones = gl.project_milestones.list(project_id=1)
# or
milestones = project.milestones.list()

You can filter the list using the following parameters:

  • iid: unique ID of the milestone for the project
  • state: either active or closed
milestones = gl.project_milestones.list(project_id=1, state='closed')
# or
milestones = project.milestones.list(state='closed')

Get a single milestone:

milestone = gl.project_milestones.get(milestone_id, project_id=1)
# or
milestone = project.milestones.get(milestone_id)

Create a milestone:

milestone = gl.project_milestones.create({'title': '1.0'}, project_id=1)
# or
milestone = project.milestones.create({'title': '1.0'})

Edit a milestone:

milestone.description = 'v 1.0 release'

Change the state of a milestone (activate / close):

# close a milestone
milestone.state_event = 'close'

# activate a milestone
milestone.state_event = 'activate'

List the issues related to a milestone:

issues = milestone.issues()

List the merge requests related to a milestone:

merge_requests = milestone.merge_requests()