Commit e682b053 authored by Dimitri Podborski's avatar Dimitri Podborski
Browse files

really simple script to try out the GitLab API

parent e9c96bf2
""" Test GitLab API
To work properly this script requires following:
1. GITLAB_TOKEN environment variable to be set to your private token.
Create your private token here: http://mpegx.int-evry.fr/software/profile/personal_access_tokens
2. pip install --upgrade python-gitlab
"""
import os
import sys
import gitlab
TOKEN = os.environ.get('GITLAB_TOKEN')
PROJECT_ID = 272
if not TOKEN:
print("No private token found, please set the GITLAB_TOKEN environment variable")
sys.exit(1)
# private token authentication
gl = gitlab.Gitlab('http://mpegx.int-evry.fr/software', private_token=TOKEN)
# get all projects
# projects = gl.projects.list(all=True)
# print(len(projects))
project = gl.projects.get(PROJECT_ID)
print(project)
# list issues
issues = project.issues.list()
print("List all issues of the project")
for issue in issues:
print('')
print(issue)
print(issue.labels)
print('_____________')
# get issue
# issue = project.issues.get(iid)
# create new issue
# issue = project.issues.create({'title': 'Created using API', 'description': 'Foobar some text here'})
# update an issue
# issue.labels = ['Bug', 'Info']
# issue.save()
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment