Add command for canceling a running a build
Description
This PR drops in a new CLI command for canceling a running build.
Note: Currently blocked on agent endpoint being added
Example usage:
buildkite-agent build cancel --build="1234"
BUILDKITE_BUILD_ID=1234 buildkite-agent build cancel
Testing
- [x] Tests have run locally (with
go test ./...). Buildkite employees may check this if the pipeline has run automatically. - [x] Code is formatted (with
go fmt ./...)
BUILDKITE_BUILD_ID=1234 buildkite-agent build cancel
Noting that accepting BUILDKITE_BUILD_ID will mean that buildkite-agent build cancel will cancel the current build if no build ID is specified
Oh, BUILDKITE_BUILD_ID is a uuid, not an ID. @dannymidnight mind updating this to reflect that?
🎵 Hello from the other side! 🎵
How does this relate to https://buildkite.com/docs/apis/rest-api/builds#cancel-a-build? I'm guessing this will eventually be hooking itself into (via the agent endpoints?) that eventual server codepath?
If so, might be nice to put in PR description to disambiguate (which may be a "me" problem because I was linked here and mildly was expecting something of the same shape as "cancel as failing", which this may be a precursor to, but isn't 1:1 that feature just yet)
How does this relate to https://buildkite.com/docs/apis/rest-api/builds#cancel-a-build? I'm guessing this will eventually be hooking itself into (via the agent endpoints?) that eventual server codepath?
@thejcannon Yep, exactly. It'll be using an agent endpoint, authenticating with an agent token rather than hitting up the bk user REST API.
was expecting something of the same shape as "cancel as failing"
Yeah we did discuss briefly whether or not it would make sense adding a "fail" flag as part of this change but landed on a build "failing" being a symptom of having a failed job. I'll have a bit more of a discussion with the team around that specific change, but I suspect it'll be tackled in addition to this change.
Here's an example of the flow:
https://github.com/user-attachments/assets/81526742-3737-41dd-b9d0-a583098d6686