Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python-gitlab API V4

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.

like image 201
Tea Worth Avatar asked Dec 05 '25 08:12

Tea Worth


1 Answers

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()

like image 133
amBear Avatar answered Dec 07 '25 21:12

amBear



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!