I'm trying to list all the variables defined in my GitLab repository (project) using the following API: https://gitlab.com/api/v4/projects/[PROJECT-ID]/variables
But, I don't get all the variables. I can see more variables defined here: https://gitlab.com/[GROUP-NAME]/[PROJECT-NAME]/-/settings/ci_cd
I also checked the following API documentation but didn't find anything to figure out the reason: GitLab > Project-level CI/CD variables API > List project variables
Why is this happening? Is there any bug in GitLab?
Note: [PROJECT-ID]
, [GROUP-NAME]
and [PROJECT-NAME]
are placeholders and will be replaced with the actual values.
I have figured it out. It seems like the list project variables
API doesn't show more than 20 variables by default. I just made a wild guess of trying out passing a page
variable with the API call and it worked. See this: https://gitlab.com/api/v4/projects/[PROJECT-ID]/variables?page=2
On the second page, the remaining (missing) variables appeared which means that they do exist and are accessible.
These details regarding this pagination variable (page
) are missing from the official documentation of GitLab's APIs (list project variables).
Note: [PROJECT-ID]
is a placeholder and will be replaced with the actual value.