Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save phaniamt/5fa9824c298556fea045b259a32c23ba to your computer and use it in GitHub Desktop.

Select an option

Save phaniamt/5fa9824c298556fea045b259a32c23ba to your computer and use it in GitHub Desktop.
How to set all existing projects to private in SonarQube
# requirements: curl, jq
# By default this script will get 100 projects at a time
# If you have more than 100 projects . run this script multiple times
USER=user
PASSWORD=password
SONAR_URL=http://localhost:9000
for pkey in `curl ${SONAR_URL}/api/components/search?qualifiers=TRK | jq -r .components[].key`; do
curl -X POST -v -u ${USER}:${PASSWORD} ${SONAR_URL}/api/projects/update_visibility?project=${pkey}\&visibility=private;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment