agent icon indicating copy to clipboard operation
agent copied to clipboard

Add command for canceling a running a build

Open dannymidnight opened this issue 1 year ago • 4 comments

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 ./...)

dannymidnight avatar Aug 28 '24 02:08 dannymidnight

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

dabarrell avatar Aug 28 '24 02:08 dabarrell

CleanShot 2024-08-28 at 12 18 40@2x

Oh, BUILDKITE_BUILD_ID is a uuid, not an ID. @dannymidnight mind updating this to reflect that?

dabarrell avatar Aug 28 '24 02:08 dabarrell

🎵 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)

thejcannon avatar Aug 29 '24 14:08 thejcannon

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.

dannymidnight avatar Sep 02 '24 00:09 dannymidnight

Here's an example of the flow:

https://github.com/user-attachments/assets/81526742-3737-41dd-b9d0-a583098d6686

dannymidnight avatar Oct 28 '24 00:10 dannymidnight