Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list a subgroup's projects using the GitLab API?

In GitLab you can create subgroups within a group and projects within those subgroups. The GitLab documentation allows you to list the subgroups of a group and the projects of a group, but I cannot find anything about listing projects of a subgroup. Does anyone know the curl command for this, or at least know that it's not supported yet?

I've tried:
curl -s -H 'PRIVATE-TOKEN: xxxxx' https://gitlab.com/api/v4/groups/mygroup/subgroups/mysubgroup/projects
curl -s -H 'PRIVATE-TOKEN: xxxxx' https://gitlab.com/api/v4/subgroups/mysubgroup/projects
and other similar variations with no luck so far.

like image 296
chacd Avatar asked Aug 23 '18 22:08

chacd


People also ask

What is the GitLab API URL?

If you're a GitLab.com user, the base URL is https://gitlab.com .

How do I find my GitLab Project ID?

On the Edit Project page there is a Project ID field in the top right corner. (You can also see the ID on the CI/CD pipelines page, in the exameple code of the Triggers section.) In older versions, you can see it on the Triggers page, in the URLs of the example code.

What is GitLab REST API?

The GitLab API allows you to perform many of the actions you typically do when using the user interface. Using the API allows us to automate the process and eliminate any user interaction.


2 Answers

Use %2f to specify full path to subgroup:

curl -s https://gitlab.com/api/v4/groups/gitlab-org%2fgitter/projects

See this issue.

like image 141
giraffes Avatar answered Oct 19 '22 13:10

giraffes


To get all the projects of group and subgroups call the api like this

curl --silent --header "Private-Token: YOUR_GITLAB_TOKEN" https://gitlab.example.com/api/v4/groups/<group_name>/projects?include_subgroups=true

or using group id

<your_gitlab-url>/api/v4/groups/<group_ID>/projects?include_subgroups=true
like image 6
Dashrath Mundkar Avatar answered Oct 19 '22 13:10

Dashrath Mundkar