Gitlab: a list of all projects and all groups

What is the easiest way to list all projects and groups in Gitlab using my personal token.

+8
source share
2 answers

If only your personal token is available, you can only use the API:

PROJECTS

Use the following to request projects:

curl "https://<host/api/v4/projects?private_token=<your private token>"

This will return you the first 20 entries. To get more you can add a parameterper_page

curl "https://<host/api/v4/projects?private_token=<your private token>&per_page=100"

With this parameter you can query from 20to 100records. https://docs.gitlab.com/ce/api/README.html#pagination

If you need all the projects, you need to go through the pages to get another page and pageparameters.

curl "https://<host/api/v4/projects?private_token=<your private token>&per_page=100&page=<page_number>"

, . curl --head. , .

:

HTTP/1.1 200 OK
Server: nginx
Date: Thu, 13 Jul 2017 17:43:24 GMT
Content-Type: application/json
Content-Length: 29428
Cache-Control: no-cache
Link: <request link>
Vary: Origin
X-Frame-Options: SAMEORIGIN
X-Next-Page: 2
X-Page: 1
X-Per-Page: 20
X-Prev-Page:
X-Request-Id: 80ecc167-4f3f-4c99-b09d-261e240e7fe9
X-Runtime: 4.117558
X-Total: 312257
X-Total-Pages: 15613
Strict-Transport-Security: max-age=31536000

- X-Total X-Total-Pages, - , - .

python - .

, -: https://docs.gitlab.com/ce/api/projects.html#projects-api

projects groups . https://docs.gitlab.com/ce/api/groups.html#list-groups


: / API Gitlab: https://about.gitlab.com/applications/#api-clients
.

+18

python . , :

import os
import gitlab

gl = gitlab.Gitlab('http://gitlab_hostname.com', 'your_private_token')
groups = gl.groups.list()
projects = gl.projects.list()
all_projects = gl.projects.list(all=True)
all_groups=gl.groups.list(all=True)
print("All groups are:",all_groups)
length=len(all_projects)
i=0
while i < length:
    project = gl.projects.get(all_projects[i].id)
    print(project)
    i=i+1
0

Source: https://habr.com/ru/post/1681309/


All Articles