Running commands like buildkite-agent secret get hello inside a container via mount-buildkite-agent fails:
$ buildkite-agent secret get test
fatal: failed to create Job API client: BUILDKITE_AGENT_JOB_API_SOCKET empty or undefined
2024-06-06 07:13:02 UTC 🚨 Error: The command exited with status 1
The mount-buildkite-agent option causes BUILDKITE_JOB_IDBUILDKITE_BUILD_IDBUILDKITE_AGENT_ACCESS_TOKEN to be passed into the container:
So it seems there's precedent for passing in everything needed to actually use buildkite-agent subcommands inside the container, which makes sense given that's the point of mounting it in.
As more things like Buildkite Secrets require interaction with the Job API, this plugin should probably mount in the socket and pass through the BUILDKITE_AGENT_JOB_API_SOCKET environment variable.
See also equivalent
docker
plugin issue at https://github.com/buildkite-plugins/docker-buildkite-plugin/issues/271Running commands like buildkite-agent secret get hello inside a container via mount-buildkite-agent fails:
The
mount-buildkite-agent
option causesBUILDKITE_JOB_ID
BUILDKITE_BUILD_ID
BUILDKITE_AGENT_ACCESS_TOKEN
to be passed into the container:https://github.com/buildkite-plugins/docker-compose-buildkite-plugin/blob/4151607f1538dfa9257d9044adde11196dc0d6da/commands/run.sh#L307-L312
So it seems there's precedent for passing in everything needed to actually use
buildkite-agent
subcommands inside the container, which makes sense given that's the point of mounting it in.As more things like Buildkite Secrets require interaction with the Job API, this plugin should probably mount in the socket and pass through the
BUILDKITE_AGENT_JOB_API_SOCKET
environment variable.