Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dimitri Podborski
AutomationTools
Commits
e682b053
Commit
e682b053
authored
Jul 13, 2020
by
Dimitri Podborski
Browse files
really simple script to try out the GitLab API
parent
e9c96bf2
Changes
1
Hide whitespace changes
Inline
Side-by-side
testAPI.py
0 → 100755
View file @
e682b053
""" 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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment