Bulk Terminate Agents

Scenario:

Update has been applied to the elastic stack (or about to) or something else like a config and must terminate all agents once existing jobs are finished. Right now having to go to the agents listing page and manually hit stop on all agents running. Not fun when we have 100+ running.
Alternatively. sometimes I do hit terminate on the ec2 instances themselves however is not graceful and running jobs will return an error and will need to retry.

Suggestion:
Either an UI option to stop all agents based on a filter or all running, or, an api call to send a stop request.

Thanks for this suggestion @neil :+1:

We don’t have something in the UI like this available but we would like to make managing agents better over time. That would include tools for bulk actions and more awareness of stacks from the dashboard.

In the meantime, you could use our API to script it with something like this:

export API_TOKEN=xxxxxxxx # (export your API Token)
curl --silent -H 'Authorization: Bearer $API_TOKEN' 'https://api.buildkite.com/v2/builds?state=scheduled' | jq '.[] | .url + "/cancel"' -r | while read -r URL; do echo "$URL to delete"; done