根据python-gitlab文档,我需要一个名为gitlab.cfg的文件,其内容应如下所示:
然后我应该能够用列表方式列出我的项目,使用以下代码:
(其中
(在gitlab.com上,而不是一个私有托管的gitlab实例中),我找不到任何关于如何做到这一点的文档。
[global]
default = gitlabcom
ssl_verify = true
timeout = 30
[gitlabcom]
url = https://gitlab.com/
private_token = PERSONAL_ACCESS_TOKEN
api_version = 4
然后我应该能够用列表方式列出我的项目,使用以下代码:
gitlab -c gitlab.cfg project list
然而,这给我列出了一些不属于我的项目,例如(列表会有所变化):
id: 13784565
path: 2019-08-25-form-from-classes
id: 13784562
path: faq
id: 13784561
path: curso-web-playground
id: 13784560
...
如果我使用curl,我会得到预期的结果:
curl --header "PRIVATE-TOKEN: PERSONAL_ACCESS_TOKEN" "https://gitlab.com/api/v4/groups/42424242/projects"
(其中
42424242
是我的群组ID。)(在gitlab.com上,而不是一个私有托管的gitlab实例中),我找不到任何关于如何做到这一点的文档。