save gitlab variables
#!/usr/bin/bash # fetch all variables of readable projects BASEURL="https://gitlab.example.org/api/v4/" GITLABTOKEN=$( cat $HOME/private/gitlab-token ) if [ -z $GITLABTOKEN ]; then echo 'please set the environment variable GITLABTOKEN' exit 10 fi TIMESTAMP=$( date -u +%Y-%m-%d ) EXPORTPATH=$HOME/private/gitlab-variables/$TIMESTAMP mkdir -p $EXPORTPATH CURL="curl -s --header PRIVATE-TOKEN:$GITLABTOKEN" $CURL "$BASEURL/admin/ci/variables" | jq -r '.[] ' > $EXPORTPATH/admin.variables.json LAST_PROJ_ID=$( $CURL "$BASEURL/projects/" | jq -r '.[].id' | sort -n | tail -1 ) #echo $LAST_PROJ_ID ID=1 until [ $ID -gt $LAST_PROJ_ID ]; do # get the short name "path" #NAME=$( $CURL "$BASEURL/projects/$PROJID/" | jq -r '.path' ) #echo ">>> $ID <<<" LONGNAME=$( $CURL "$BASEURL/projects/$ID/" | jq -r '.path_with_namespace' | sed 's#/#__#g' ) #echo $LONGNAME if [ "$LONGNAME" == "null" ]; then ((ID++)) continue fi VARIABLES=$( $CURL "$BASEURL/projects/$ID/variables" | jq -r '.[]' ) if [[ ! -z "$VARIABLES" |]]; then printf "$VARIABLES" > $EXPORTPATH/project.variables.$ID.$LONGNAME.json fi ((ID++)) done # FINI
gilt für alle Tipps, Tricks & Spickzettel:
dies sind einfache, teils banale Notizen für meinen persönlichen Gebrauch,
die hier eher zufällig auch öffentlich lesbar sind
(vielleicht hilft es ja jemandem weiter). Verwendung auf eigene Gefahr
Fehler-Hinweise, Dankesschreiben , etc. bitte an: web.25@unixwitch.de
weitere Tools / Spickzettel