Skip to content

Instantly share code, notes, and snippets.

@nicobytes
Last active January 14, 2020 23:24
Show Gist options
  • Save nicobytes/f36d9d56cb6fe0f2e7ecb0d0c0d098d5 to your computer and use it in GitHub Desktop.
Save nicobytes/f36d9d56cb6fe0f2e7ecb0d0c0d098d5 to your computer and use it in GitHub Desktop.
milestone report gitlab
import requests
project_id = 'xxxxx'
labels = ['New funcionality', 'Support', 'Maintenance']
milestone = 'v1.6.0'
state = 'closed'
url = f'https://gitlab.com/api/v4/projects/{project_id}/issues'
headers = {'Authorization': 'Bearer xxxxxxxx'} # https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#limiting-scopes-of-a-personal-access-token
md = f'## Milestone:{milestone} \n'
for label in labels:
url_by_label = f'{url}?labels={label}&milestone={milestone}&state={state}'
response = requests.get(url=url_by_label, headers=headers)
issues = response.json()
md = md + f'### {label} ({len(issues)})\n'
for issue in issues:
title = issue['title']
issue_id = issue['references']['short']
md = md + f'- {issue_id}:{title} \n'
with open(f'milestone-{milestone}.md', 'w') as outfile:
outfile.write(md)
outfile.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment