Skip to content

feat(buildkite): pass through BuildMetadata#206

Merged
JamyDev merged 1 commit into
mainfrom
feat/buildkite-metadata
Jun 5, 2026
Merged

feat(buildkite): pass through BuildMetadata#206
JamyDev merged 1 commit into
mainfrom
feat/buildkite-metadata

Conversation

@JamyDev
Copy link
Copy Markdown
Contributor

@JamyDev JamyDev commented Jun 5, 2026

What?

Thread BuildMetadata through the Buildkite BuildRunner so callers can attach attributes (requester, ticket ID, trace ID) at trigger time and recover them from any subsequent Status call
— with no local state required.

  • Trigger: JSON-encodes the caller-supplied metadata into a new SQ_METADATA env var on the Buildkite build request. Omitted when metadata is nil/empty, keeping the payload clean for
    callers that don't use it.
  • Status: decodes SQ_METADATA from the env vars Buildkite echoes back on the build object, merges with "url", and returns the combined map. Decode errors are swallowed — a corrupt
    env var must not fail a status poll.
  • client.go: adds Env map[string]string to buildResponse to capture the echoed env vars from the Buildkite GET response.

Why?

The BuildRunner interface documents that metadata "MAY be persisted or echoed back via Status" — but the original implementation discarded it with _. Buildkite's REST API echoes the
build's env map on every GET response, which means the metadata can round-trip through Buildkite itself rather than requiring a separate store or in-memory cache. This keeps the
implementation stateless and satisfies the interface contract at no extra infrastructure cost.

Tests

  • TestTrigger_WithMetadata_SetsEnvVar — captures the outbound request body, verifies SQ_METADATA is present, and round-trips the JSON back into BuildMetadata to assert key equality.
  • TestTrigger_NilMetadata_NoMetadataEnvVar — verifies nil metadata produces no SQ_METADATA key (i.e. the env map stays clean).
  • TestStatus_EchosCallerMetadata — serves a build response with SQ_METADATA set; asserts all caller keys and "url" are present in the returned metadata.
  • TestStatus_NoMetadata_ReturnsOnlyURL — build response without SQ_METADATA; asserts the returned map is exactly {"url": "..."}, confirming the no-metadata path is unaffected.

@JamyDev JamyDev requested review from a team, behinddwalls and sbalabanov as code owners June 5, 2026 04:04
Base automatically changed from feat/buildkite-buildrunner to main June 5, 2026 05:05
@JamyDev JamyDev force-pushed the feat/buildkite-metadata branch from e3b790b to 55cf865 Compare June 5, 2026 05:07
@JamyDev JamyDev enabled auto-merge June 5, 2026 05:07
@JamyDev JamyDev added this pull request to the merge queue Jun 5, 2026
Merged via the queue into main with commit b5b24db Jun 5, 2026
15 checks passed
@JamyDev JamyDev deleted the feat/buildkite-metadata branch June 5, 2026 05:12
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.

2 participants