buildkite-plugins / docker-compose-buildkite-plugin

🐳⚡️ Run build scripts, and build + push images, w/ Docker Compose
MIT License
171 stars 138 forks source link

`mount-buildkite-agent` should mount `BUILDKITE_AGENT_JOB_API_SOCKET` #443

Closed pda closed 3 weeks ago

pda commented 2 months ago

See also equivalent docker plugin issue at https://github.com/buildkite-plugins/docker-buildkite-plugin/issues/271

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_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.

toote commented 3 weeks ago

Closed as it was implemented in #444