Fetch projects greater than 100 from gitlab for sourcegraph projectQuery

守給你的承諾、 提交于 2020-05-17 06:45:17

问题


I am updating a sourcegraph's projectQuery configuration for gitlab but gitlab's (for the version I have) max count per page is 100 therefore, I can not get all the projects in a single query because I have more than 100 projects although I can add additional queries to fetch multiple projects but this I have to monitor and keep track of if the new projects are added that does not seems ntutive.

project query could look like this

"projectQuery": [
        "../v4/projects?per_page=100&page=1",
        "../v4/projects?per_page=100&page=2",
        ...
        ...
    ]

how can I improve this, a script could be better or extracts all the projects and add them to projects's key in the config? I am asking here because this looks a very generic question


回答1:


Try using python-gitlab

From reading the documentation, it seems that

gitlab project list --all

ought to return a list of all projects.

You can install it with:

pip install python-gitlab


来源:https://stackoverflow.com/questions/61664510/fetch-projects-greater-than-100-from-gitlab-for-sourcegraph-projectquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!