Created
September 5, 2019 17:51
-
-
Save matheusneder/66054a496ee2dfd193d985225564bc98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
TOKEN=xxx | |
AUTH="Basic $(echo -n $TOKEN: | base64)" | |
SONARAPI="http://sonarqube/api" | |
for projKey in $(curl -s -X GET $SONARAPI/projects/search -H "Authorization: $AUTH" | \ | |
jq -r '.components[].key') | |
do | |
projKey=$(echo $projKey | xargs) | |
echo "++++ PROJ: $projKey ++++" | |
for branchName in $(curl -s -X GET "$SONARAPI/project_branches/list?project=$projKey" \ | |
-H "Authorization: $AUTH" | \ | |
jq -r '.branches[] | select(.type == "LONG") | select (.isMain == false) | .name') | |
do | |
branchName=$(echo $branchName | xargs) | |
echo "---- DELETING BRANCH $branchName -----" | |
curl -s -X POST \ | |
"$SONARAPI/project_branches/delete?project=$projKey&branch=$branchName" \ | |
-H "Authorization: $AUTH" | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment