I use following part of the bash script to retrieve all IDs of the projects within a given GitLab group using API calls. There are about 250 projects in the group. But when use this script it only retrieves 100 projects ids. How do I retrieve all of the project ids?
page=1 #------Retrieve the IDs of the non archived projects in the group
while [[ "$page" != "0" ]]
do
urlCheck=`curl -s "$GIT_API/groups?private_token=$GIT_TOKEN&per_page=100&page=$page" | jq -r ".[] | .name"`
if [[ -n $urlCheck ]]
then
PROJECT_ID_ARRAY+=($(curl -sS --request GET --header "PRIVATE-TOKEN: $GIT_TOKEN" "$GIT_API/groups/1079/projects?include_subgroups=true&per_page=100&page=${page}" | jq -r '.[] .id'))
page=$((page+1))
else
page=0
fi
done
You can get the id of all the projects using GitLab rest API, I have made a single command to do so via curl :
curl -s --location --request GET --header 'PRIVATE-TOKEN:<PRIVATE_TOKEN>' '$CI_API_V4_URL/groups/'$GROUPID'/projects' | sed 's/,/\n/g' | grep -w "id" | awk -F ':' '{print $2}' | sed -s 's/{"id"//g
'
Make sure you give input of GROUPID as per your group id.
Ref: https://docs.gitlab.com/ee/api/projects.html#list-all-projects