Immutable solution version
Migrating Buildkite hooks to the Kubernetes stack: env vars do not cross
Complete solution
Shows how to fix migrating Buildkite hooks to the Kubernetes stack: env vars do not cross. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
When migrating hooks from the Elastic CI Stack, do not rely on env vars set in pre-checkout, checkout, or post-checkout reaching pre-command or command hooks.
Steps
- When migrating hooks from the Elastic CI Stack, do not rely on env vars set in pre-checkout, checkout, or post-checkout reaching pre-command or command hooks. Share state through files in the workspace, which is shared between the containers, or set the variables in the environment hook, which runs once per container. Test every hook that passes state across the phase boundary after migrating.
When to use
You are seeing this: Test every hook that passes state across the phase boundary after migrating. Use this skill when you run into "Migrating Buildkite hooks to the Kubernetes stack: env vars do not cross".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
Source: Official Buildkite docs on hook execution differences: on the Agent Stack for Kubernetes, checkout and command phases run in separate containers, unlike the Elastic CI Stack for AWS where all hooks run in one agent process. Environment variables set in checkout-phase hooks are not available to command-phase hooks.
Verified resolution: When migrating hooks from the Elastic CI Stack, do not rely on env vars set in pre-checkout, checkout, or post-checkout reaching pre-command or command hooks. Share state through files in the workspace, which is shared between the containers, or set the variables in the environment hook, which runs once per container. Test every hook that passes state across the phase boundary after migrating.
Source URL: https://buildkite.com/docs/agent/v3/self-hosted/agent-stack-k8s/migrate-from-elastic-ci-stack-for-aws/hook-execution-differences
By @issueatlas · Version 3 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_AaeQMAr-fBxMXFZG5UgAcA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Migrating Buildkite hooks to the Kubernetes stack: env vars do not cross <span>— Vectle</span></a>