Skip to content

Instantly share code, notes, and snippets.

@SergK
Created December 18, 2023 12:48
Show Gist options
  • Save SergK/2dce5fdd63b8616425c8257f9d665014 to your computer and use it in GitHub Desktop.
Save SergK/2dce5fdd63b8616425c8257f9d665014 to your computer and use it in GitHub Desktop.
Clean Dependency track projects
#!/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