Reputation: 77
Does anyone know if Python-GitLab is still supported? I am trying to simply print the list of my project from GitLab but it doesn't work.
Example:
projects = gl.projects.list()
for project in projects:
print(project)
I tried many things and it doesn't work. Maybe it's not working with gitlab.com?
Any helpful information is greatly appreciated.
Upvotes: 3
Views: 3754
Reputation: 1196
I tested python-gitlab today and it still works. This is my sample python file below. I defined "ACCESS_TOKEN" in a .env file in the project. You will need an access token to connect to the Gitlab instance.
import gitlab
import os
from envparse import env
if os.path.isfile('.env'):
env.read_envfile()
ACCESS_TOKEN = env('ACCESS_TOKEN')
gl = gitlab.Gitlab('https://gitlab.com/', ACCESS_TOKEN)
def get_projects():
projects = gl.projects.list(owned=True)
for project in projects:
print(project.name)
def main():
get_projects()
main()
Upvotes: 4