Created
December 18, 2023 12:48
-
-
Save SergK/2dce5fdd63b8616425c8257f9d665014 to your computer and use it in GitHub Desktop.
Clean Dependency track projects
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 -ex | |
API_KEY="YOUR_KEY" | |
DT_URL="https://example.com" | |
# Execute the GET request and save the response to a variable | |
response=$(curl -X GET "${DT_URL}/api/v1/search/project?query=test*" -H "X-Api-Key: ${API_KEY}") | |
# Use jq to parse the JSON response and extract the UUIDs | |
uuids=$(echo $response | jq -r '.results.project[].uuid') | |
# Use a for loop to process each UUID | |
for uuid in $uuids | |
do | |
curl -X DELETE "${DT_URL}/api/v1/project/${uuid}" -H "X-Api-Key: ${API_KEY}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment