Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit a0737096 authored by Christophe Chaudier's avatar Christophe Chaudier :rocket:
Browse files

Merge branch '21-api-get-all-projects-and-groups-and-not-only-the-fist-page' into 'master'

Resolve "(api) get all projects and groups and not only the fist page"

Closes #21

See merge request !17
parents 51910ba9 e40de642
No related branches found
No related tags found
1 merge request!17Resolve "(api) get all projects and groups and not only the fist page"
Pipeline #2662 passed with warnings
......@@ -36,6 +36,7 @@ Options :
# https://docs.gitlab.com/ee/user/group/settings/import_export.html#rate-limits
readonly DELAY_EXPORT=10
readonly DELAY_EXPORT_DL=60
readonly API_PER_PAGE=2
# ---[ Vars ]---
config_file='.mygb_config'
......@@ -130,8 +131,17 @@ _api() {
"${gitlab_url}api/v4/${path}"
}
_nb_of_projects_page() {
_api GET "groups/${group_url_encoded}/projects?include_subgroups=true&per_page=${API_PER_PAGE}" --head \
| grep 'x-total-pages'| cut -d ':' -f 2 | tr -d "[:space:]"
}
_get_projects_from_group() {
_api GET "groups/${group_url_encoded}/projects?include_subgroups=true" | jq -r '.[].path_with_namespace'
for (( page=1; page<=$(_nb_of_projects_page); page++ )); do
_api GET "groups/${group_url_encoded}/projects?include_subgroups=true&per_page=${API_PER_PAGE}&page=${page}" \
| jq -r '.[].path_with_namespace'
done
}
_get_project_info() {
......@@ -233,16 +243,26 @@ _export_group() {
fi
}
_nb_of_groups_page() {
_api GET "groups?owned=true&top_level_only=true&per_page=${API_PER_PAGE}" --head \
| grep 'x-total-pages'| cut -d ':' -f 2 | tr -d "[:space:]"
}
_get_my_groups() {
_api GET "groups?owned=true&top_level_only=true" | jq -r '.[].path'
for (( page=1; page<=$(_nb_of_groups_page); page++ )); do
_api GET "groups?owned=true&top_level_only=true&per_page=${API_PER_PAGE}&page=${page}" | jq -r '.[].path'
done
}
_export_all(){
if [[ ${export_all} == true ]]; then
echo "Export all my groups"
local nb_group_exported=0
for group in $(_get_my_groups); do
_export_group
((nb_group_exported++))
done
echo "Number of group exported : ${nb_group_exported}"
fi
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment