Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command for canceling a running a build #2958

Merged
merged 3 commits into from
Oct 28, 2024
Merged

Conversation

dannymidnight
Copy link
Contributor

@dannymidnight dannymidnight commented Aug 28, 2024

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_BUILD_ID=1234 buildkite-agent build cancel

Testing

  • Tests have run locally (with go test ./...). Buildkite employees may check this if the pipeline has run automatically.
  • Code is formatted (with go fmt ./...)

@dabarrell
Copy link
Contributor

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
Copy link
Contributor

dabarrell commented Aug 28, 2024

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?

clicommand/build_cancel.go Outdated Show resolved Hide resolved
clicommand/build_cancel.go Outdated Show resolved Hide resolved
$ buildkite-agent build cancel

# Cancel a different build
$ buildkite-agent build cancel --build "01234567-89ab-cdef-0123-456789abcdef"`
Copy link
Contributor Author

@dannymidnight dannymidnight Aug 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on @DrJosh9000's suggestion, is this clear enough for you @dabarrell that we require a UUID?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed this, sorry! yep!

@thejcannon
Copy link

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

@dannymidnight
Copy link
Contributor Author

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
Copy link
Contributor Author

Here's an example of the flow:

Screen.Recording.2024-10-28.at.11.55.01.am.mov

Copy link
Contributor

@DrJosh9000 DrJosh9000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🍏

@dannymidnight dannymidnight merged commit 0c8ce81 into main Oct 28, 2024
1 check passed
@dannymidnight dannymidnight deleted the cancel-build branch October 28, 2024 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants