Created
March 27, 2024 00:13
-
-
Save mcncl/de282b9c39669df683715be3ffb351ca to your computer and use it in GitHub Desktop.
Cancel all running Buildkite builds
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 | |
# Make API call to retrieve initial objects and extract URLs | |
urls=($(http -I -A bearer --auth "$TOKEN" GET "https://api.buildkite.com/v2/organizations/ORG/builds?state=running" | jq -r '.[] | .url')) | |
# Loop through URLs, append /cancel, and make API calls | |
for url in "${urls[@]}"; do | |
cancel_url="${url}/cancel" | |
echo "Making API call to cancel: $cancel_url" | |
# Make API call here (curl example provided) | |
# Replace 'curl' with your API call command | |
curl -s -H "Authorization: Bearer $TOKEN" -X PUT "$cancel_url" >> /dev/null | |
echo "Cancelled $cancel_url :white_check_mark:" | |
done | |
## state=running can bu adjusted to be any state, such as state=scheduled |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment