Skip to content

Set last hook exit status for unwrapped hooks - #4286

Open
francoiscampbell wants to merge 3 commits into
buildkite:mainfrom
francoiscampbell:francois/set-unwrapped-hook-exit-status
Open

Set last hook exit status for unwrapped hooks#4286
francoiscampbell wants to merge 3 commits into
buildkite:mainfrom
francoiscampbell:francois/set-unwrapped-hook-exit-status

Conversation

@francoiscampbell

@francoiscampbell francoiscampbell commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Description

Unwrapped hooks (non-shell scripts and binaries) currently do not update BUILDKITE_LAST_HOOK_EXIT_STATUS. This differs from wrapped shell hooks and can leave the variable unset or stale for subsequent hooks, even when the unwrapped hook succeeded.

Set the variable from the unwrapped process result so later hooks observe the same exit-status behavior regardless of hook type.

Context

This surfaced after converting a plugin command hook from Bash to Python. Its pre-exit hook used BUILDKITE_LAST_HOOK_EXIT_STATUS to report the command result, but the value was no longer populated after the successful Python hook.

Changes

  • Set BUILDKITE_LAST_HOOK_EXIT_STATUS after running an unwrapped hook, using the same shell.ExitCode conversion as wrapped hooks.
  • Add regression coverage for successful and failing unwrapped hooks.

Testing

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

Passed:

go test ./internal/job -run '^TestRunUnwrappedHookSetsLastHookExitStatus$' -count=1

Affiliation (optional, external contributors)

Instacart

Disclosures / Credits

OpenAI Codex via Pi helped diagnose the behaviour, implement the change, and write the regression test. The PR was then reviewed and refined by a human.

@francoiscampbell
francoiscampbell requested review from a team as code owners August 28, 2026 20:50
@francoiscampbell
francoiscampbell marked this pull request as draft August 28, 2026 20:52
@francoiscampbell

Copy link
Copy Markdown
Contributor Author

Could a maintainer please add the bug label? This fixes BUILDKITE_LAST_HOOK_EXIT_STATUS not being updated for unwrapped hooks. External contributors do not have permission to add labels in this repository.

@francoiscampbell
francoiscampbell marked this pull request as ready for review August 28, 2026 21:13
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.

1 participant